zio-http
zio-http copied to clipboard
Implement client connection pooling
Is your feature request related to a problem? Please describe.
The performance of the Http client can be improved through connection pooling.
Describe the solution you'd like
Connection pooling is easier to implement with a keyed pool, which ZIO 2 does not yet support.
We can build a ZKeyedPool
here and upstream to ZIO 2 later:
trait ZKeyedPool[+Error, -Key, Item] {
def get(key: Key)(implicit trace: Trace): ZIO[Scope, Error, Item]
def invalidate(item: Item)(implicit trace: Trace): UIO[Unit]
}
object ZKeyedPool {
def makeWith[K, R, E, A](get: K => ZIO[R, E, A], total: => Range, maxPerKey: => Int)(implicit trace: Trace): ZKeyedPool[E, K, A] = ???
}
Then we can utilize this connection pool in the implementation of Client
to ensure that we have ready-to-use connections to common targets.
Describe alternatives you've considered
None.