Class: Sidekiq::CircuitBreaker::Manager
- Inherits:
-
Object
- Object
- Sidekiq::CircuitBreaker::Manager
show all
- Includes:
- API
- Defined in:
- lib/sidekiq/circuit_breaker/manager.rb
Instance Method Summary
collapse
Methods included from API
#circuit_opened?, #failure_count_for_scope, #open_circuit, #register_failure_for_scope, #register_success_for_scope, #time_to_open_the_circuit
Constructor Details
#initialize(scope, options) ⇒ Manager
Returns a new instance of Manager.
7
8
9
10
|
# File 'lib/sidekiq/circuit_breaker/manager.rb', line 7
def initialize(scope, options)
@scope = scope
@options = options
end
|
Instance Method Details
#closed? ⇒ Boolean
21
22
23
|
# File 'lib/sidekiq/circuit_breaker/manager.rb', line 21
def closed?
!open?
end
|
#evaluate_failure ⇒ Object
12
13
14
15
|
# File 'lib/sidekiq/circuit_breaker/manager.rb', line 12
def evaluate_failure
count = register_failure
open if count >= @options.failure_threshold
end
|
#failure_count ⇒ Object
25
26
27
|
# File 'lib/sidekiq/circuit_breaker/manager.rb', line 25
def failure_count
failure_count_for_scope(@scope)
end
|
#open ⇒ Object
29
30
31
|
# File 'lib/sidekiq/circuit_breaker/manager.rb', line 29
def open
open_circuit(@scope, @options.max_open_time)
end
|
#open? ⇒ Boolean
17
18
19
|
# File 'lib/sidekiq/circuit_breaker/manager.rb', line 17
def open?
circuit_opened?(@scope)
end
|
#register_failure ⇒ Object
37
38
39
|
# File 'lib/sidekiq/circuit_breaker/manager.rb', line 37
def register_failure
register_failure_for_scope(@scope)
end
|
#register_success ⇒ Object
45
46
47
|
# File 'lib/sidekiq/circuit_breaker/manager.rb', line 45
def register_success
register_success_for_scope(@scope)
end
|
#time_to_open ⇒ Object
33
34
35
|
# File 'lib/sidekiq/circuit_breaker/manager.rb', line 33
def time_to_open
time_to_open_the_circuit(@scope)
end
|