Class: CI::Queue::CircuitBreaker::MaxConsecutiveFailures

Inherits:
Object
  • Object
show all
Defined in:
lib/ci/queue/circuit_breaker.rb

Instance Method Summary collapse

Constructor Details

#initialize(max_consecutive_failures:) ⇒ MaxConsecutiveFailures

Returns a new instance of MaxConsecutiveFailures.



54
55
56
57
# File 'lib/ci/queue/circuit_breaker.rb', line 54

def initialize(max_consecutive_failures:)
  @max = max_consecutive_failures
  @consecutive_failures = 0
end

Instance Method Details

#messageObject



71
72
73
# File 'lib/ci/queue/circuit_breaker.rb', line 71

def message
  'This worker is exiting early because it encountered too many consecutive test failures, probably because of some corrupted state.'
end

#open?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/ci/queue/circuit_breaker.rb', line 67

def open?
  @consecutive_failures >= @max
end

#report_failure!Object



59
60
61
# File 'lib/ci/queue/circuit_breaker.rb', line 59

def report_failure!
  @consecutive_failures += 1
end

#report_success!Object



63
64
65
# File 'lib/ci/queue/circuit_breaker.rb', line 63

def report_success!
  @consecutive_failures = 0
end