TL;DR:
I have a “go to” default structure for services.
Up until today I used tapir with akka-http.
I want to try out ZIO, and need guidance.
I submitted a template repo with short README that explains the structure, and motivation:
There are 2 server modules there.
server
which uses my regular akka-http code, and it works. You can justserver/run
in sbt, and try it out.zerver
which uses zio-http instead, and so far I wasn’t able to understand how everything should be stitched together.
Currently I get weird compile errors like:
[error] /home/hochgi/dev/tapir-service/zerver/src/main/scala/com/hochgi/example/zerver/Main.scala:28:63: type mismatch;
[error] found : List[sttp.tapir.ztapir.ZServerEndpoint[_, Any]]
[error] (which expands to) List[sttp.tapir.server.ServerEndpoint[Any,[β$0$]zio.ZIO[_$1,Throwable,β$0$]] forSome { type _$1 }]
[error] required: List[sttp.tapir.ztapir.ZServerEndpoint[Any,sttp.capabilities.zio.ZioStreams]]
[error] (which expands to) List[sttp.tapir.server.ServerEndpoint[sttp.capabilities.zio.ZioStreams,[β$0$]zio.ZIO[Any,Throwable,β$0$]]]
[error] val app = ZioHttpInterpreter(serverOptions).toHttp(Routes.all)
[error] ^
[error] /home/hochgi/dev/tapir-service/zerver/src/main/scala/com/hochgi/example/zerver/Routes.scala:19:73: type mismatch;
[error] found : sttp.tapir.server.ServerEndpoint[Any,_1[_]] where type _1[_] >: zio.ZIO[Any,Throwable,_] <: zio.ZIO[com.typesafe.config.Config,Throwable,_]
[error] required: sttp.tapir.ztapir.ZServerEndpoint[Any,Any]
[error] (which expands to) sttp.tapir.server.ServerEndpoint[Any,[β$0$]zio.ZIO[Any,Throwable,β$0$]]
[error] val apiEndpoints: List[ZServerEndpoint[Any, Any]] = endpoints.map(_._2)
[error] ^
[error] /home/hochgi/dev/tapir-service/zerver/src/main/scala/com/hochgi/example/zerver/matapi/Info.scala:23:63: zio.URIO[com.typesafe.config.Config, _] takes no type parameters, expected: 1
[error] allConfigEndpoint => allConfigEndpoint.serverLogicSuccess[URIO[Config, _]](_ => zioConfig)
[error] ^
[error] /home/hochgi/dev/tapir-service/zerver/src/main/scala/com/hochgi/example/zerver/matapi/Info.scala:26:50: zio.URIO[com.typesafe.config.Config, _] takes no type parameters, expected: 1
[error] configEndpoint => configEndpoint.serverLogic[URIO[Config, _]]{ path =>
[error] ^
which I struggle to decipher.
Not sure if it’s more of a ZIO question or a tapir question, but figured it wouldn’t hurt to ask.
Any help, guidance, or links to relevant material I should read is greatly appreciated.
Thanks!