Class: Gracefully::ShortCircuitedCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/gracefully/short_circuited_command.rb

Instance Method Summary collapse

Methods inherited from Command

normalize_arguments

Constructor Details

#initialize(*args, &block) ⇒ ShortCircuitedCommand

Returns a new instance of ShortCircuitedCommand.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/gracefully/short_circuited_command.rb', line 7

def initialize(*args, &block)
  super

  @circuit_breaker = Gracefully::CircuitBreaker.new(
    try_close_after: @options[:try_close_after],
    health: Gracefully::ConsecutiveFailuresBasedHealth.new(
      become_unhealthy_after_consecutive_failures: @options[:allowed_failures],
      counter: @options[:counter]
    )
  )
end

Instance Method Details

#call(*args, &block) ⇒ Object



19
20
21
# File 'lib/gracefully/short_circuited_command.rb', line 19

def call(*args, &block)
  @circuit_breaker.execute { super }
end