net-http-persistent icon indicating copy to clipboard operation
net-http-persistent copied to clipboard

Feature Request: Allow custom pool_timeout configuration

Open nachojorge opened this issue 9 months ago • 0 comments

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_timeout option in Net::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. šŸ™Œ

nachojorge avatar Feb 14 '25 17:02 nachojorge