Project

http-cage

0.0
No release in over 3 years
Low commit activity in last 3 years
Global timeouts for Net::HTTP.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

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