mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 01:58:41 -05:00
Fix RuboCop style violations in circuit_breaker.rb
This commit is contained in:
parent
efc31a3280
commit
07a73d68ae
1 changed files with 3 additions and 7 deletions
|
|
@ -9,7 +9,7 @@ module Vmpooler
|
||||||
# - OPEN: Provider is failing, reject requests immediately (fail fast)
|
# - OPEN: Provider is failing, reject requests immediately (fail fast)
|
||||||
# - HALF_OPEN: Testing if provider has recovered with limited requests
|
# - HALF_OPEN: Testing if provider has recovered with limited requests
|
||||||
class CircuitBreaker
|
class CircuitBreaker
|
||||||
STATES = [:closed, :open, :half_open].freeze
|
STATES = %i[closed open half_open].freeze
|
||||||
|
|
||||||
class CircuitOpenError < StandardError; end
|
class CircuitOpenError < StandardError; end
|
||||||
|
|
||||||
|
|
@ -133,9 +133,7 @@ module Vmpooler
|
||||||
@failure_count = 0
|
@failure_count = 0
|
||||||
@logger.log('d', "[+] [circuit_breaker] '#{@name}' successful test request (#{@success_count}/#{@half_open_attempts})")
|
@logger.log('d', "[+] [circuit_breaker] '#{@name}' successful test request (#{@success_count}/#{@half_open_attempts})")
|
||||||
|
|
||||||
if @success_count >= @half_open_attempts
|
transition_to_closed if @success_count >= @half_open_attempts
|
||||||
transition_to_closed
|
|
||||||
end
|
|
||||||
when :open
|
when :open
|
||||||
# Should not happen, but reset if we somehow get a success
|
# Should not happen, but reset if we somehow get a success
|
||||||
transition_to_closed
|
transition_to_closed
|
||||||
|
|
@ -151,9 +149,7 @@ module Vmpooler
|
||||||
case @state
|
case @state
|
||||||
when :closed
|
when :closed
|
||||||
@logger.log('d', "[!] [circuit_breaker] '#{@name}' failure #{@failure_count}/#{@failure_threshold}: #{error.class}")
|
@logger.log('d', "[!] [circuit_breaker] '#{@name}' failure #{@failure_count}/#{@failure_threshold}: #{error.class}")
|
||||||
if @failure_count >= @failure_threshold
|
transition_to_open if @failure_count >= @failure_threshold
|
||||||
transition_to_open
|
|
||||||
end
|
|
||||||
when :half_open
|
when :half_open
|
||||||
@logger.log('d', "[!] [circuit_breaker] '#{@name}' failed during half-open test")
|
@logger.log('d', "[!] [circuit_breaker] '#{@name}' failed during half-open test")
|
||||||
transition_to_open
|
transition_to_open
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue