semian 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dd9c2d960a88c72716c280d2c26f8d81501bb090
4
- data.tar.gz: f797fadf0c2848492fd22b291231b07bc63aa370
3
+ metadata.gz: 06426c58d5f63b75836c2ee4de57b5546695bdb3
4
+ data.tar.gz: cc392c302a788c6ac542d8d71dbb56fd1ffba899
5
5
  SHA512:
6
- metadata.gz: cb62bd5e7269858b6f0a2108e3cab1e75a73e687daddad3f9c993b4be66768f59cdbbf38074bb4636def924521e537d1a9ce031b304efc12c61ed0f0b8694d35
7
- data.tar.gz: 652545ff897ce72a76473075e2e71e8269655887bd360fce2ecf22c63c46ae38ca533357918df2fbf6a8b36712a9e9764f343691c9029871725934c204c63d8a
6
+ metadata.gz: 930c8b5d1a0df10034388bd50552782edc95cf309d85dbf4759a91d20898924ca8f4eea7695ecbc2877b0ea8ca7db811380a47938ed2652cf70403f8870f9ce6
7
+ data.tar.gz: dde2cbf4a37f1fba443091c17ea7b8ff1d28f424dbb362bfcdd5b3964194bd26f29516b518652cdf78eb62bdec1a61139f3b2ed266bb40270e0dfd6924bc4344
@@ -2,7 +2,7 @@ module Semian
2
2
  class CircuitBreaker #:nodoc:
3
3
  extend Forwardable
4
4
 
5
- def_delegators :@state, :closed?, :open?, :half_open?
5
+ def_delegators :@state, :closed?, :open?, :half_open!
6
6
 
7
7
  attr_reader :name, :half_open_resource_timeout
8
8
 
@@ -21,8 +21,7 @@ module Semian
21
21
 
22
22
  def acquire(resource = nil, &block)
23
23
  return yield if disabled?
24
-
25
- half_open if open? && error_timeout_expired?
24
+ half_open! if half_open?
26
25
 
27
26
  raise OpenCircuitError unless request_allowed?
28
27
 
@@ -38,11 +37,12 @@ module Semian
38
37
  result
39
38
  end
40
39
 
40
+ def half_open?
41
+ (open? && error_timeout_expired?) || @state.half_open?
42
+ end
43
+
41
44
  def request_allowed?
42
- closed? ||
43
- half_open? ||
44
- # The circuit breaker is officially open, but it will transition to half-open on the next attempt.
45
- (open? && error_timeout_expired?)
45
+ closed? || half_open?
46
46
  end
47
47
 
48
48
  def mark_failed(_error)
@@ -27,7 +27,7 @@ module Semian
27
27
  @value = :closed
28
28
  end
29
29
 
30
- def half_open
30
+ def half_open!
31
31
  @value = :half_open
32
32
  end
33
33
 
@@ -1,3 +1,3 @@
1
1
  module Semian
2
- VERSION = '0.8.0'
2
+ VERSION = '0.8.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semian
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Francis
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-07-31 00:00:00.000000000 Z
13
+ date: 2018-08-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake-compiler