lib/ci/queue/circuit_breaker.rb in ci-queue-0.17.2 vs lib/ci/queue/circuit_breaker.rb in ci-queue-0.18.0
- old
+ new
@@ -1,9 +1,9 @@
# frozen_string_literal: true
module CI
module Queue
- class CircuitBreaker
+ module CircuitBreaker
module Disabled
extend self
def report_failure!
end
@@ -48,28 +48,30 @@
def current_timestamp
Time.now.to_i
end
end
- def initialize(max_consecutive_failures:)
- @max = max_consecutive_failures
- @consecutive_failures = 0
- end
+ class MaxConsecutiveFailures
+ def initialize(max_consecutive_failures:)
+ @max = max_consecutive_failures
+ @consecutive_failures = 0
+ end
- def report_failure!
- @consecutive_failures += 1
- end
+ def report_failure!
+ @consecutive_failures += 1
+ end
- def report_success!
- @consecutive_failures = 0
- end
+ def report_success!
+ @consecutive_failures = 0
+ end
- def open?
- @consecutive_failures >= @max
- end
+ def open?
+ @consecutive_failures >= @max
+ end
- def message
- 'This worker is exiting early because it encountered too many consecutive test failures, probably because of some corrupted state.'
+ def message
+ 'This worker is exiting early because it encountered too many consecutive test failures, probably because of some corrupted state.'
+ end
end
end
end
end