Skip to content

Latest commit

 

History

History
66 lines (42 loc) · 1.86 KB

README.md

File metadata and controls

66 lines (42 loc) · 1.86 KB

HTTP-Cage.

Gem Version wercker status

Global timeouts for Ruby's Net::HTTP.

Why.

Net::HTTP by default has a connect timeout of 60 seconds and a request timeout of 60 seconds, a 2 minutes worst-case scenario timeout, with auto-retry.

These defaults are kinda dangerous in a micro-services environment, where requests should happen fast or just timeout, to avoid server processes locking.

This gem lets you globally restrict timeouts of Net::HTTP calls, so that all gems and libraries that use Net::HTTP will timeout fast.

Installation.

  • Add it to your Gemfile:
gem 'http-cage'

Usage.

# Initialize the cage in your app initializer.
HTTPCage.timeout(connection: 3, request: 5)

# Increase global timeouts in a delayed job, for example.
HTTPCage.timeout(connection: 10, request: 30)

Test.

bundle exec rake test:all

Demo

asciicast

Contribute

  • We use GitHub issues to discuss everything: features, bugs, docs.
  • Before sending a pull request always open an issue.

Maintainers

Artwork

License

MIT License