Skip to content

Feature Request: Allow custom pool_timeout configuration#156

Description

@nachojorge

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鈥檇 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. 馃檶

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions