Connection Pooling support in faraday adapters #1421
-
I was looking for connection pooling support in different faraday adapters and found #1024 and #1006 which show work in progress. #1006 mentions that certain adapters like Net-Http and Excon are incompatible by design to support connection pooling. Are there any other options available to add support for connection pooling without depending on the underlying support of adapters? There are certain gems that add generic support for connection pooling regardless of the underlying Ruby client e.g https://github.com/mperham/connection_pool. Can this gem help in adding connection pooling support in adapters like net-http, excon etc? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey @MaryamAdnan3 👋, In fact, in your code snippet you're actually storing That is where the So in short, your code works and doesn't really need any change to Faraday to support it 👍, but it only makes sense under certain circumstances (i.e. the underlying adapter keeps the connection open). |
Beta Was this translation helpful? Give feedback.
Hey @MaryamAdnan3 👋,
connection_pool
is exactly the gem I used in #1006, but that has nothing to do with HTTP connections. That gem is simply providing you with mutexed access to shared resources. This is obviously useful for managing connections across threads/fibers, but you could technically put whatever you want in there 😄.In fact, in your code snippet you're actually storing
Faraday::Connection
objects in the pool. This actually works, but I doubt is achieving the desired behaviour.For example, if your
Faraday.default_adapter
isnet_http
, that means that when you check in a connection and use it to make a request, you're still creating a newNet::HTTP
object, which will open a new …