No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
A circuit breaker for use with eventmachine and em-http-request.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.15
~> 5.0
~> 10.0
~> 2.0

Runtime

 Project Readme

EventMachine::CircuitBreaker

Build Status

This project is still in active development

This library is meant to provide a simple way to enable the circuit breaker pattern to em-http requests by providing some middleware that can prevent requests and manage circuit state based on response parameters.

Installation

Add this line to your application's Gemfile:

gem 'eventmachine-circuit_breaker'

And then execute:

$ bundle

Usage

require 'eventmachine/circuit_breaker'
require 'em-http-request'

# circuit breaker for all requests
EventMachine.run do
  EventMachine::HttpRequest.use EventMachine::CircuitBreaker
  # now you can use em-http-request as normal
end

# circuit breaker per connection
EventMachine.run do
  connection = EventMachine::HttpRequest.new("http://example.com")
  connection.use EventMachine::CircuitBreaker
  connection.get
  # ...
end

# sharing circuit state
EventMachine.run do
  circuit_strategy = EventMachine::CircuitBreaker::Strategy::Basic.new

  connection_1 = EventMachine::HttpRequest.new("http://example.com/foo")
  connection_1.use EventMachine::CircuitBreaker, strategy: circuit_strategy
  connection_1.get
  # ...

  connection_2 = EventMachine::HttpRequest.new("http://example.com/bar")
  connection_2.use EventMachine::CircuitBreaker, strategy: circuit_strategy
  connection_2.get
  # ...
end

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/dcoxall/eventmachine-circuit_breaker.