assent icon indicating copy to clipboard operation
assent copied to clipboard

Add connection pool to Mint HTTP adapter (turn it into a GenServer)

Open danschultzer opened this issue 6 years ago • 1 comments

Based on https://github.com/danschultzer/pow_assent/issues/89

So the current implementation of PowAssent.HTTPAdapter.Mint doesn't pool HTTP/2 connections. For it to do that, I'll need to set it up as a GenServer. This way all connections can be kept open and all requests can be faster and more efficient. As new requests are coming in, the connections will be created if they don't exist in the GenServer state.

I haven't decided yet if the GenServer should be an extra layer on top of the current implementation so they work in parallel, or it should just replace it entirely and you are required to start it up to use Mint. I feel the latter is the better choice, since there is not really much of a point in using Mint without connection pool.

Any feedback/thoughts are welcome, I only have a superficial understanding of HTTP/2 🙂

danschultzer avatar Sep 25 '19 00:09 danschultzer

There is https://hexdocs.pm/nimble_pool/NimblePool.html, but more interesting, there is also https://hexdocs.pm/finch/Finch.html and from the readme:

Pools will be started for each configured {scheme, host, port} when Finch is started. For any unconfigured {scheme, host, port}, the pool will be started the first time it is requested. Note pools are not automatically terminated if they are unused, so Finch is best suited when you are requesting a known list of static hosts.

Schultzer avatar Dec 08 '20 23:12 Schultzer