circuit_breaker 1.1.0 → 1.1.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 +7 -0
- data/History.txt +5 -0
- data/circuit_breaker.gemspec +1 -1
- data/lib/circuit_breaker/circuit_broken_exception.rb +1 -1
- data/lib/circuit_breaker/circuit_state.rb +7 -7
- data/lib/circuit_breaker/version.rb +1 -1
- metadata +51 -36
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 878d179cb18117bfd31851db4290e31a051e0631
|
4
|
+
data.tar.gz: f03a183efddb0c5a6106100f8d7bf9f5e6489f5b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 32ddfd097a904c51224efcd2f9c3b4cade17383d6ea749dbc21cff16f5b87b97664c69529a196244f980ea1125d5cc63fff6913fce3439a5cf2914e238ad2a0c
|
7
|
+
data.tar.gz: 9105785a5f0b372816d12afae455c70c1937608919e38671a41d26a46259c49750c86ffb72783b6f0758f044a95c045224b7bfde72b06833ea0a3e1de9e1552e
|
data/History.txt
CHANGED
data/circuit_breaker.gemspec
CHANGED
@@ -9,32 +9,32 @@ class CircuitBreaker::CircuitState
|
|
9
9
|
|
10
10
|
include AASM
|
11
11
|
|
12
|
-
|
12
|
+
aasm.state :half_open
|
13
13
|
|
14
|
-
|
14
|
+
aasm.state :open
|
15
15
|
|
16
|
-
|
16
|
+
aasm.state :closed, :enter => :reset_failure_count
|
17
17
|
|
18
|
-
|
18
|
+
aasm.initial_state :closed
|
19
19
|
|
20
20
|
#
|
21
21
|
# Trips the circuit breaker into the open state where it will immediately fail.
|
22
22
|
#
|
23
|
-
|
23
|
+
aasm.event :trip do
|
24
24
|
transitions :to => :open, :from => [:closed, :half_open]
|
25
25
|
end
|
26
26
|
|
27
27
|
#
|
28
28
|
# Transitions from an open state to a half_open state.
|
29
29
|
#
|
30
|
-
|
30
|
+
aasm.event :attempt_reset do
|
31
31
|
transitions :to => :half_open, :from => [:open]
|
32
32
|
end
|
33
33
|
|
34
34
|
#
|
35
35
|
# Close the circuit from an open or half open state.
|
36
36
|
#
|
37
|
-
|
37
|
+
aasm.event :reset do
|
38
38
|
transitions :to => :closed, :from => [:open, :half_open]
|
39
39
|
end
|
40
40
|
|
metadata
CHANGED
@@ -1,79 +1,95 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: circuit_breaker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.1.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Will Sargent
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-03-06 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: aasm
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rspec
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
|
-
description:
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
55
|
+
description: |-
|
56
|
+
CircuitBreaker is a relatively simple Ruby mixin that will wrap
|
57
|
+
a call to a given service in a circuit breaker pattern.
|
58
|
+
|
59
|
+
The circuit starts off "closed" meaning that all calls will go through.
|
60
|
+
However, consecutive failures are recorded and after a threshold is reached,
|
61
|
+
the circuit will "trip", setting the circuit into an "open" state.
|
62
|
+
|
63
|
+
In an "open" state, every call to the service will fail by raising
|
64
|
+
CircuitBrokenException.
|
65
|
+
|
66
|
+
The circuit will remain in an "open" state until the failure timeout has
|
67
|
+
elapsed.
|
68
|
+
|
69
|
+
After the failure_timeout has elapsed, the circuit will go into
|
70
|
+
a "half open" state and the call will go through. A failure will
|
71
|
+
immediately pop the circuit open again, and a success will close the
|
72
|
+
circuit and reset the failure count.
|
73
|
+
|
74
|
+
require 'circuit_breaker'
|
75
|
+
class TestService
|
76
|
+
|
77
|
+
include CircuitBreaker
|
78
|
+
|
79
|
+
def call_remote_service() ...
|
80
|
+
|
81
|
+
circuit_method :call_remote_service
|
82
|
+
|
83
|
+
# Optional
|
84
|
+
circuit_handler do |handler|
|
85
|
+
handler.logger = Logger.new(STDOUT)
|
86
|
+
handler.failure_threshold = 5
|
87
|
+
handler.failure_timeout = 5
|
88
|
+
end
|
89
|
+
|
90
|
+
# Optional
|
91
|
+
circuit_handler_class MyCustomCircuitHandler
|
92
|
+
end
|
77
93
|
email:
|
78
94
|
- will.sargent@gmail.com
|
79
95
|
executables: []
|
@@ -98,6 +114,7 @@ files:
|
|
98
114
|
- spec/spec_helper.rb
|
99
115
|
homepage: http://github.com/wsargent/circuit_breaker
|
100
116
|
licenses: []
|
117
|
+
metadata: {}
|
101
118
|
post_install_message:
|
102
119
|
rdoc_options:
|
103
120
|
- --main
|
@@ -106,22 +123,20 @@ rdoc_options:
|
|
106
123
|
require_paths:
|
107
124
|
- lib
|
108
125
|
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
-
none: false
|
110
126
|
requirements:
|
111
|
-
- -
|
127
|
+
- - '>='
|
112
128
|
- !ruby/object:Gem::Version
|
113
129
|
version: '0'
|
114
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
-
none: false
|
116
131
|
requirements:
|
117
|
-
- -
|
132
|
+
- - '>='
|
118
133
|
- !ruby/object:Gem::Version
|
119
134
|
version: '0'
|
120
135
|
requirements: []
|
121
136
|
rubyforge_project: will_sargent
|
122
|
-
rubygems_version:
|
137
|
+
rubygems_version: 2.0.3
|
123
138
|
signing_key:
|
124
|
-
specification_version:
|
139
|
+
specification_version: 4
|
125
140
|
summary: CircuitBreaker is a relatively simple Ruby mixin that will wrap a call to
|
126
141
|
a given service in a circuit breaker pattern
|
127
142
|
test_files:
|