Class: HTTPigeon::Middleware::CircuitBreaker

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/httpigeon/middleware/circuit_breaker.rb

Defined Under Namespace

Classes: FailedRequestError

Instance Method Summary collapse

Constructor Details

#initialize(app, fuse_config) ⇒ CircuitBreaker

Returns a new instance of CircuitBreaker.



8
9
10
11
12
# File 'lib/httpigeon/middleware/circuit_breaker.rb', line 8

def initialize(app, fuse_config)
  super(app)

  @fuse_config = fuse_config
end

Instance Method Details

#on_complete(env) ⇒ Object

Raises:



14
15
16
17
18
# File 'lib/httpigeon/middleware/circuit_breaker.rb', line 14

def on_complete(env)
  return unless failed_request?(env.status)

  raise FailedRequestError, response_values(env)
end