Skip to content

Commit

Permalink
Make request_allowed? thread safe
Browse files Browse the repository at this point in the history
  • Loading branch information
byroot committed Aug 10, 2016
1 parent 27d0175 commit 655b3c7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/semian/circuit_breaker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def initialize(name, exceptions:, success_threshold:, error_threshold:, error_ti
end

def acquire
half_open if open? && error_timeout_expired?

raise OpenCircuitError unless request_allowed?

result = nil
Expand All @@ -30,9 +32,7 @@ def acquire
end

def request_allowed?
return true if closed?
half_open if error_timeout_expired?
!open?
closed? || half_open? || (open? && error_timeout_expired?)
end

def mark_failed(_error)
Expand Down

0 comments on commit 655b3c7

Please sign in to comment.