zio-http
zio-http copied to clipboard
Move client and server to interfaces + implementations + layers
Is your feature request related to a problem? Please describe.
The server and client are objects, whose methods use the environment to obtain their dependencies. This was a ZIO 1.0 pattern. In ZIO 2, it's more idiomatic for such functionality to be moved to service traits, whose classes consume dependencies through constructors, and whose construction is itself described by a layer.
Describe the solution you'd like
There should exist Client
and Server
traits, which define what it means for something to be a Client
or Server
, and the dependencies and resources necessary to create these should be bundled up into layers.
This will allow the client and server to consume resources, have their own dependencies, and possibly even have test implementations, while at the same time following the newer ZIO 2 module pattern, which embraces constructor-based dependency injection.
Describe alternatives you've considered
None.
I'll do this.
Actually @gciuloaica is already on this!
One change that we should consider while doing this change is to make sure that the client and the server use the same event loop and the same transport.
@devsprint See comment from @tusharmath on sharing event loop & transport between client & server.
@jdegoes @tusharmath the event loop and transport between client and sever sharing will be in a new PR.
I think this can be closed now