net-http-persistent
net-http-persistent copied to clipboard
Feature Request: Allow custom pool_timeout configuration
Hi! š
I'd like to propose adding a configurable pool_timeout option to this gem. Currently, the timeout for waiting on a connection is 0.5 seconds, as defined by the pop method in ConnectionPool::TimedStack. While this is a reasonable default, applications with different concurrency needs may benefit from being able to adjust this value.
Why This Matters
- Some applications with high request rates might need a shorter timeout to fail fast.
- Applications with longer request times might prefer a higher timeout to avoid request failures due to temporary connection unavailability.
- Making this configurable gives developers more control over connection handling based on their needs.
Proposed Change
- Introduce a
pool_timeoutoption inNet::HTTP::Persistent. - Pass this value directly to
ConnectionPool. - Default to 0.5s to maintain current behavior but allow customization.
Example Usage
http = Net::HTTP::Persistent.new(name: "my-client", pool_timeout: 2) # 2s timeout
If no connection is available within 2 seconds, an exception should be raised.
Additional Notes
- Would you be open to this addition?
- Iād be happy to work on a PR if the feature aligns with the project goals.
- Let me know if you have any feedback or preferences regarding implementation.
Thanks for your time! Looking forward to your thoughts. š