ninenines / gun

HTTP/1.1, HTTP/2, Websocket client (and more) for Erlang/OTP.
ISC License
891 stars 232 forks source link

Implemented 'start_pool_if_missing' logic #295

Open umbec opened 2 years ago

umbec commented 2 years ago

Hi @essen!

I have this patch that expands the start_pool_if_missing logic, allocating a new pool on demand.

If a pool for a certain authority already exists, the checkout process succeed, and the request goes on as always. In the other case, a new pool is allocated with the opts() passed to the start_pool_if_missing flag.

This code has been working on my services for a while, and without the presumption of being perfect or to address all the open points in the pool management, it can brings an useful improvement to the current implementation.

If you have any objection or suggestion to the implementation, let me know.

essen commented 2 years ago

Thanks! I will have to review and that will take a while as I'm in the middle of a very heavy set of changes. But the initial feeling is good.