stoplight 3.0.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +176 -198
- data/lib/stoplight/builder.rb +68 -0
- data/lib/stoplight/circuit_breaker.rb +92 -0
- data/lib/stoplight/configurable.rb +95 -0
- data/lib/stoplight/configuration.rb +126 -0
- data/lib/stoplight/data_store/base.rb +9 -0
- data/lib/stoplight/data_store/memory.rb +46 -5
- data/lib/stoplight/data_store/redis.rb +75 -6
- data/lib/stoplight/default.rb +2 -0
- data/lib/stoplight/error.rb +1 -0
- data/lib/stoplight/light/deprecated.rb +44 -0
- data/lib/stoplight/light/lockable.rb +45 -0
- data/lib/stoplight/light/runnable.rb +34 -16
- data/lib/stoplight/light.rb +69 -63
- data/lib/stoplight/rspec/generic_notifier.rb +42 -0
- data/lib/stoplight/rspec.rb +3 -0
- data/lib/stoplight/version.rb +1 -1
- data/lib/stoplight.rb +33 -10
- data/spec/spec_helper.rb +7 -0
- data/spec/stoplight/builder_spec.rb +165 -0
- data/spec/stoplight/circuit_breaker_spec.rb +35 -0
- data/spec/stoplight/configurable_spec.rb +25 -0
- data/spec/stoplight/data_store/base_spec.rb +7 -0
- data/spec/stoplight/data_store/memory_spec.rb +12 -123
- data/spec/stoplight/data_store/redis_spec.rb +28 -129
- data/spec/stoplight/error_spec.rb +10 -0
- data/spec/stoplight/light/lockable_spec.rb +93 -0
- data/spec/stoplight/light/runnable_spec.rb +12 -233
- data/spec/stoplight/light_spec.rb +4 -28
- data/spec/stoplight/notifier/generic_spec.rb +35 -35
- data/spec/stoplight/notifier/io_spec.rb +1 -0
- data/spec/stoplight/notifier/logger_spec.rb +3 -0
- data/spec/stoplight_spec.rb +17 -6
- data/spec/support/configurable.rb +69 -0
- data/spec/support/data_store/base/clear_failures.rb +18 -0
- data/spec/support/data_store/base/clear_state.rb +20 -0
- data/spec/support/data_store/base/get_all.rb +44 -0
- data/spec/support/data_store/base/get_failures.rb +30 -0
- data/spec/support/data_store/base/get_state.rb +7 -0
- data/spec/support/data_store/base/names.rb +29 -0
- data/spec/support/data_store/base/record_failures.rb +70 -0
- data/spec/support/data_store/base/set_state.rb +15 -0
- data/spec/support/data_store/base/with_notification_lock.rb +27 -0
- data/spec/support/data_store/base.rb +21 -0
- data/spec/support/database_cleaner.rb +26 -0
- data/spec/support/exception_helpers.rb +9 -0
- data/spec/support/light/runnable/color.rb +79 -0
- data/spec/support/light/runnable/run.rb +247 -0
- data/spec/support/light/runnable.rb +4 -0
- metadata +56 -225
- data/lib/stoplight/notifier/bugsnag.rb +0 -37
- data/lib/stoplight/notifier/hip_chat.rb +0 -43
- data/lib/stoplight/notifier/honeybadger.rb +0 -44
- data/lib/stoplight/notifier/pagerduty.rb +0 -21
- data/lib/stoplight/notifier/raven.rb +0 -40
- data/lib/stoplight/notifier/rollbar.rb +0 -39
- data/lib/stoplight/notifier/slack.rb +0 -21
- data/spec/stoplight/notifier/bugsnag_spec.rb +0 -90
- data/spec/stoplight/notifier/hip_chat_spec.rb +0 -91
- data/spec/stoplight/notifier/honeybadger_spec.rb +0 -88
- data/spec/stoplight/notifier/pagerduty_spec.rb +0 -40
- data/spec/stoplight/notifier/raven_spec.rb +0 -90
- data/spec/stoplight/notifier/rollbar_spec.rb +0 -90
- data/spec/stoplight/notifier/slack_spec.rb +0 -46
@@ -0,0 +1,247 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.shared_examples 'Stoplight::Light::Runnable#run' do
|
4
|
+
let(:code) { -> { code_result } }
|
5
|
+
let(:code_result) { random_string }
|
6
|
+
let(:fallback) { ->(_) { fallback_result } }
|
7
|
+
let(:fallback_result) { random_string }
|
8
|
+
let(:name) { random_string }
|
9
|
+
let(:notifiers) { [notifier] }
|
10
|
+
let(:notifier) { Stoplight::Notifier::IO.new(io) }
|
11
|
+
let(:io) { StringIO.new }
|
12
|
+
|
13
|
+
before { light.with_notifiers(notifiers) }
|
14
|
+
|
15
|
+
shared_examples 'when the light is green' do
|
16
|
+
before { light.data_store.clear_failures(light) }
|
17
|
+
|
18
|
+
it 'runs the code' do
|
19
|
+
expect(run).to eql(code_result)
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'with some failures' do
|
23
|
+
before { light.data_store.record_failure(light, failure) }
|
24
|
+
|
25
|
+
it 'clears the failures' do
|
26
|
+
run
|
27
|
+
expect(light.data_store.get_failures(light).size).to eql(0)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'when the code is failing' do
|
32
|
+
let(:code_result) { raise error }
|
33
|
+
|
34
|
+
it 're-raises the error' do
|
35
|
+
expect { run }.to raise_error(error.class)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'records the failure' do
|
39
|
+
expect(light.data_store.get_failures(light).size).to eql(0)
|
40
|
+
begin
|
41
|
+
run
|
42
|
+
rescue error.class
|
43
|
+
nil
|
44
|
+
end
|
45
|
+
expect(light.data_store.get_failures(light).size).to eql(1)
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'when we did not send notifications yet' do
|
49
|
+
it 'notifies when transitioning to red' do
|
50
|
+
light.threshold.times do
|
51
|
+
expect(io.string).to eql('')
|
52
|
+
begin
|
53
|
+
run
|
54
|
+
rescue error.class
|
55
|
+
nil
|
56
|
+
end
|
57
|
+
end
|
58
|
+
expect(io.string).to_not eql('')
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'when we already sent notifications' do
|
63
|
+
before do
|
64
|
+
light.data_store.with_notification_lock(light, Stoplight::Color::GREEN, Stoplight::Color::RED) {}
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'does not send new notifications' do
|
68
|
+
light.threshold.times do
|
69
|
+
expect(io.string).to eql('')
|
70
|
+
begin
|
71
|
+
run
|
72
|
+
rescue error.class
|
73
|
+
nil
|
74
|
+
end
|
75
|
+
end
|
76
|
+
expect(io.string).to eql('')
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'notifies when transitioning to red' do
|
81
|
+
light.threshold.times do
|
82
|
+
expect(io.string).to eql('')
|
83
|
+
begin
|
84
|
+
run
|
85
|
+
rescue error.class
|
86
|
+
nil
|
87
|
+
end
|
88
|
+
end
|
89
|
+
expect(io.string).to_not eql('')
|
90
|
+
end
|
91
|
+
|
92
|
+
context 'with an error handler' do
|
93
|
+
let(:result) do
|
94
|
+
run
|
95
|
+
expect(false).to be(true)
|
96
|
+
rescue error.class
|
97
|
+
expect(true).to be(true)
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'records the failure when the handler does nothing' do
|
101
|
+
light.with_error_handler { |_error, _handler| }
|
102
|
+
expect { result }
|
103
|
+
.to change { light.data_store.get_failures(light).size }
|
104
|
+
.by(1)
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'records the failure when the handler calls handle' do
|
108
|
+
light.with_error_handler { |error, handle| handle.call(error) }
|
109
|
+
expect { result }
|
110
|
+
.to change { light.data_store.get_failures(light).size }
|
111
|
+
.by(1)
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'does not record the failure when the handler raises' do
|
115
|
+
light.with_error_handler { |error, _handle| raise error }
|
116
|
+
expect { result }
|
117
|
+
.to_not change { light.data_store.get_failures(light).size }
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
context 'with a fallback' do
|
122
|
+
before { light.with_fallback(&fallback) }
|
123
|
+
|
124
|
+
it 'runs the fallback' do
|
125
|
+
expect(run).to eql(fallback_result)
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'passes the error to the fallback' do
|
129
|
+
light.with_fallback do |e|
|
130
|
+
expect(e).to eql(error)
|
131
|
+
fallback_result
|
132
|
+
end
|
133
|
+
expect(run).to eql(fallback_result)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
context 'when the data store is failing' do
|
139
|
+
let(:error_notifier) { ->(_) {} }
|
140
|
+
let(:error) { StandardError.new('something went wrong') }
|
141
|
+
|
142
|
+
before do
|
143
|
+
expect(data_store).to receive(:clear_failures) { raise error }
|
144
|
+
|
145
|
+
light.with_error_notifier(&error_notifier)
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'runs the code' do
|
149
|
+
expect(run).to eql(code_result)
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'notifies about the error' do
|
153
|
+
has_notified = false
|
154
|
+
light.with_error_notifier do |e|
|
155
|
+
has_notified = true
|
156
|
+
expect(e).to eq(error)
|
157
|
+
end
|
158
|
+
run
|
159
|
+
expect(has_notified).to eql(true)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
shared_examples 'when the light is yellow' do
|
165
|
+
let(:failure) { Stoplight::Failure.new(error.class.name, error.message, Time.new - light.cool_off_time) }
|
166
|
+
let(:failure2) { Stoplight::Failure.new(error.class.name, error.message, Time.new - light.cool_off_time - 10) }
|
167
|
+
|
168
|
+
before do
|
169
|
+
light.with_threshold(2)
|
170
|
+
light.data_store.record_failure(light, failure2)
|
171
|
+
light.data_store.record_failure(light, failure)
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'runs the code' do
|
175
|
+
expect(run).to eql(code_result)
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'notifies when transitioning to green' do
|
179
|
+
expect { run }
|
180
|
+
.to change(io, :string)
|
181
|
+
.from(be_empty)
|
182
|
+
.to(/Switching \w+ from red to green/)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
shared_examples 'when the light is red' do
|
187
|
+
let(:other) do
|
188
|
+
Stoplight::Failure.new(error.class.name, error.message, Time.new - light.cool_off_time)
|
189
|
+
end
|
190
|
+
|
191
|
+
before do
|
192
|
+
light.with_threshold(2)
|
193
|
+
light.data_store.record_failure(light, other)
|
194
|
+
light.data_store.record_failure(light, failure)
|
195
|
+
end
|
196
|
+
|
197
|
+
it 'raises an error' do
|
198
|
+
expect { run }.to raise_error(Stoplight::Error::RedLight)
|
199
|
+
end
|
200
|
+
|
201
|
+
it 'uses the name as the error message' do
|
202
|
+
expect do
|
203
|
+
run
|
204
|
+
end.to raise_error(Stoplight::Error::RedLight, light.name)
|
205
|
+
end
|
206
|
+
|
207
|
+
context 'with a fallback' do
|
208
|
+
before { light.with_fallback(&fallback) }
|
209
|
+
|
210
|
+
it 'runs the fallback' do
|
211
|
+
expect(run).to eql(fallback_result)
|
212
|
+
end
|
213
|
+
|
214
|
+
it 'does not pass anything to the fallback' do
|
215
|
+
light.with_fallback do |e|
|
216
|
+
expect(e).to eql(nil)
|
217
|
+
fallback_result
|
218
|
+
end
|
219
|
+
expect(run).to eql(fallback_result)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
context 'with code block' do
|
225
|
+
subject(:light) { Stoplight::Light.new(name) }
|
226
|
+
|
227
|
+
def run
|
228
|
+
light.run(&code)
|
229
|
+
end
|
230
|
+
|
231
|
+
it_behaves_like 'when the light is green'
|
232
|
+
it_behaves_like 'when the light is yellow'
|
233
|
+
it_behaves_like 'when the light is red'
|
234
|
+
end
|
235
|
+
|
236
|
+
context 'without code block' do
|
237
|
+
subject(:light) { Stoplight::Light.new(name, &code) }
|
238
|
+
|
239
|
+
def run
|
240
|
+
light.run
|
241
|
+
end
|
242
|
+
|
243
|
+
it_behaves_like 'when the light is green'
|
244
|
+
it_behaves_like 'when the light is yellow'
|
245
|
+
it_behaves_like 'when the light is red'
|
246
|
+
end
|
247
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stoplight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cameron Desautels
|
@@ -10,218 +10,22 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2023-08-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
16
|
+
name: redlock
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
19
|
- - "~>"
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
22
|
-
type: :
|
21
|
+
version: '1.0'
|
22
|
+
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: '
|
29
|
-
- !ruby/object:Gem::Dependency
|
30
|
-
name: bugsnag
|
31
|
-
requirement: !ruby/object:Gem::Requirement
|
32
|
-
requirements:
|
33
|
-
- - "~>"
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version: '4.0'
|
36
|
-
type: :development
|
37
|
-
prerelease: false
|
38
|
-
version_requirements: !ruby/object:Gem::Requirement
|
39
|
-
requirements:
|
40
|
-
- - "~>"
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: '4.0'
|
43
|
-
- !ruby/object:Gem::Dependency
|
44
|
-
name: fakeredis
|
45
|
-
requirement: !ruby/object:Gem::Requirement
|
46
|
-
requirements:
|
47
|
-
- - "~>"
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: '0.5'
|
50
|
-
type: :development
|
51
|
-
prerelease: false
|
52
|
-
version_requirements: !ruby/object:Gem::Requirement
|
53
|
-
requirements:
|
54
|
-
- - "~>"
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version: '0.5'
|
57
|
-
- !ruby/object:Gem::Dependency
|
58
|
-
name: hipchat
|
59
|
-
requirement: !ruby/object:Gem::Requirement
|
60
|
-
requirements:
|
61
|
-
- - "~>"
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
version: '1.5'
|
64
|
-
type: :development
|
65
|
-
prerelease: false
|
66
|
-
version_requirements: !ruby/object:Gem::Requirement
|
67
|
-
requirements:
|
68
|
-
- - "~>"
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
version: '1.5'
|
71
|
-
- !ruby/object:Gem::Dependency
|
72
|
-
name: honeybadger
|
73
|
-
requirement: !ruby/object:Gem::Requirement
|
74
|
-
requirements:
|
75
|
-
- - "~>"
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '2.5'
|
78
|
-
type: :development
|
79
|
-
prerelease: false
|
80
|
-
version_requirements: !ruby/object:Gem::Requirement
|
81
|
-
requirements:
|
82
|
-
- - "~>"
|
83
|
-
- !ruby/object:Gem::Version
|
84
|
-
version: '2.5'
|
85
|
-
- !ruby/object:Gem::Dependency
|
86
|
-
name: pagerduty
|
87
|
-
requirement: !ruby/object:Gem::Requirement
|
88
|
-
requirements:
|
89
|
-
- - "~>"
|
90
|
-
- !ruby/object:Gem::Version
|
91
|
-
version: 2.1.1
|
92
|
-
type: :development
|
93
|
-
prerelease: false
|
94
|
-
version_requirements: !ruby/object:Gem::Requirement
|
95
|
-
requirements:
|
96
|
-
- - "~>"
|
97
|
-
- !ruby/object:Gem::Version
|
98
|
-
version: 2.1.1
|
99
|
-
- !ruby/object:Gem::Dependency
|
100
|
-
name: rake
|
101
|
-
requirement: !ruby/object:Gem::Requirement
|
102
|
-
requirements:
|
103
|
-
- - "~>"
|
104
|
-
- !ruby/object:Gem::Version
|
105
|
-
version: '13.0'
|
106
|
-
type: :development
|
107
|
-
prerelease: false
|
108
|
-
version_requirements: !ruby/object:Gem::Requirement
|
109
|
-
requirements:
|
110
|
-
- - "~>"
|
111
|
-
- !ruby/object:Gem::Version
|
112
|
-
version: '13.0'
|
113
|
-
- !ruby/object:Gem::Dependency
|
114
|
-
name: redis
|
115
|
-
requirement: !ruby/object:Gem::Requirement
|
116
|
-
requirements:
|
117
|
-
- - "~>"
|
118
|
-
- !ruby/object:Gem::Version
|
119
|
-
version: '3.2'
|
120
|
-
type: :development
|
121
|
-
prerelease: false
|
122
|
-
version_requirements: !ruby/object:Gem::Requirement
|
123
|
-
requirements:
|
124
|
-
- - "~>"
|
125
|
-
- !ruby/object:Gem::Version
|
126
|
-
version: '3.2'
|
127
|
-
- !ruby/object:Gem::Dependency
|
128
|
-
name: rspec
|
129
|
-
requirement: !ruby/object:Gem::Requirement
|
130
|
-
requirements:
|
131
|
-
- - "~>"
|
132
|
-
- !ruby/object:Gem::Version
|
133
|
-
version: '3.3'
|
134
|
-
type: :development
|
135
|
-
prerelease: false
|
136
|
-
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
requirements:
|
138
|
-
- - "~>"
|
139
|
-
- !ruby/object:Gem::Version
|
140
|
-
version: '3.3'
|
141
|
-
- !ruby/object:Gem::Dependency
|
142
|
-
name: rubocop
|
143
|
-
requirement: !ruby/object:Gem::Requirement
|
144
|
-
requirements:
|
145
|
-
- - "~>"
|
146
|
-
- !ruby/object:Gem::Version
|
147
|
-
version: 1.0.0
|
148
|
-
type: :development
|
149
|
-
prerelease: false
|
150
|
-
version_requirements: !ruby/object:Gem::Requirement
|
151
|
-
requirements:
|
152
|
-
- - "~>"
|
153
|
-
- !ruby/object:Gem::Version
|
154
|
-
version: 1.0.0
|
155
|
-
- !ruby/object:Gem::Dependency
|
156
|
-
name: sentry-raven
|
157
|
-
requirement: !ruby/object:Gem::Requirement
|
158
|
-
requirements:
|
159
|
-
- - "~>"
|
160
|
-
- !ruby/object:Gem::Version
|
161
|
-
version: '1.2'
|
162
|
-
type: :development
|
163
|
-
prerelease: false
|
164
|
-
version_requirements: !ruby/object:Gem::Requirement
|
165
|
-
requirements:
|
166
|
-
- - "~>"
|
167
|
-
- !ruby/object:Gem::Version
|
168
|
-
version: '1.2'
|
169
|
-
- !ruby/object:Gem::Dependency
|
170
|
-
name: simplecov
|
171
|
-
requirement: !ruby/object:Gem::Requirement
|
172
|
-
requirements:
|
173
|
-
- - "~>"
|
174
|
-
- !ruby/object:Gem::Version
|
175
|
-
version: '0.21'
|
176
|
-
type: :development
|
177
|
-
prerelease: false
|
178
|
-
version_requirements: !ruby/object:Gem::Requirement
|
179
|
-
requirements:
|
180
|
-
- - "~>"
|
181
|
-
- !ruby/object:Gem::Version
|
182
|
-
version: '0.21'
|
183
|
-
- !ruby/object:Gem::Dependency
|
184
|
-
name: simplecov-lcov
|
185
|
-
requirement: !ruby/object:Gem::Requirement
|
186
|
-
requirements:
|
187
|
-
- - "~>"
|
188
|
-
- !ruby/object:Gem::Version
|
189
|
-
version: '0.8'
|
190
|
-
type: :development
|
191
|
-
prerelease: false
|
192
|
-
version_requirements: !ruby/object:Gem::Requirement
|
193
|
-
requirements:
|
194
|
-
- - "~>"
|
195
|
-
- !ruby/object:Gem::Version
|
196
|
-
version: '0.8'
|
197
|
-
- !ruby/object:Gem::Dependency
|
198
|
-
name: slack-notifier
|
199
|
-
requirement: !ruby/object:Gem::Requirement
|
200
|
-
requirements:
|
201
|
-
- - "~>"
|
202
|
-
- !ruby/object:Gem::Version
|
203
|
-
version: '1.3'
|
204
|
-
type: :development
|
205
|
-
prerelease: false
|
206
|
-
version_requirements: !ruby/object:Gem::Requirement
|
207
|
-
requirements:
|
208
|
-
- - "~>"
|
209
|
-
- !ruby/object:Gem::Version
|
210
|
-
version: '1.3'
|
211
|
-
- !ruby/object:Gem::Dependency
|
212
|
-
name: timecop
|
213
|
-
requirement: !ruby/object:Gem::Requirement
|
214
|
-
requirements:
|
215
|
-
- - "~>"
|
216
|
-
- !ruby/object:Gem::Version
|
217
|
-
version: '0.8'
|
218
|
-
type: :development
|
219
|
-
prerelease: false
|
220
|
-
version_requirements: !ruby/object:Gem::Requirement
|
221
|
-
requirements:
|
222
|
-
- - "~>"
|
223
|
-
- !ruby/object:Gem::Version
|
224
|
-
version: '0.8'
|
28
|
+
version: '1.0'
|
225
29
|
description: An implementation of the circuit breaker pattern.
|
226
30
|
email:
|
227
31
|
- camdez@gmail.com
|
@@ -235,7 +39,11 @@ files:
|
|
235
39
|
- LICENSE.md
|
236
40
|
- README.md
|
237
41
|
- lib/stoplight.rb
|
42
|
+
- lib/stoplight/builder.rb
|
43
|
+
- lib/stoplight/circuit_breaker.rb
|
238
44
|
- lib/stoplight/color.rb
|
45
|
+
- lib/stoplight/configurable.rb
|
46
|
+
- lib/stoplight/configuration.rb
|
239
47
|
- lib/stoplight/data_store.rb
|
240
48
|
- lib/stoplight/data_store/base.rb
|
241
49
|
- lib/stoplight/data_store/memory.rb
|
@@ -244,23 +52,23 @@ files:
|
|
244
52
|
- lib/stoplight/error.rb
|
245
53
|
- lib/stoplight/failure.rb
|
246
54
|
- lib/stoplight/light.rb
|
55
|
+
- lib/stoplight/light/deprecated.rb
|
56
|
+
- lib/stoplight/light/lockable.rb
|
247
57
|
- lib/stoplight/light/runnable.rb
|
248
58
|
- lib/stoplight/notifier.rb
|
249
59
|
- lib/stoplight/notifier/base.rb
|
250
|
-
- lib/stoplight/notifier/bugsnag.rb
|
251
60
|
- lib/stoplight/notifier/generic.rb
|
252
|
-
- lib/stoplight/notifier/hip_chat.rb
|
253
|
-
- lib/stoplight/notifier/honeybadger.rb
|
254
61
|
- lib/stoplight/notifier/io.rb
|
255
62
|
- lib/stoplight/notifier/logger.rb
|
256
|
-
- lib/stoplight/
|
257
|
-
- lib/stoplight/
|
258
|
-
- lib/stoplight/notifier/rollbar.rb
|
259
|
-
- lib/stoplight/notifier/slack.rb
|
63
|
+
- lib/stoplight/rspec.rb
|
64
|
+
- lib/stoplight/rspec/generic_notifier.rb
|
260
65
|
- lib/stoplight/state.rb
|
261
66
|
- lib/stoplight/version.rb
|
262
67
|
- spec/spec_helper.rb
|
68
|
+
- spec/stoplight/builder_spec.rb
|
69
|
+
- spec/stoplight/circuit_breaker_spec.rb
|
263
70
|
- spec/stoplight/color_spec.rb
|
71
|
+
- spec/stoplight/configurable_spec.rb
|
264
72
|
- spec/stoplight/data_store/base_spec.rb
|
265
73
|
- spec/stoplight/data_store/memory_spec.rb
|
266
74
|
- spec/stoplight/data_store/redis_spec.rb
|
@@ -268,23 +76,33 @@ files:
|
|
268
76
|
- spec/stoplight/default_spec.rb
|
269
77
|
- spec/stoplight/error_spec.rb
|
270
78
|
- spec/stoplight/failure_spec.rb
|
79
|
+
- spec/stoplight/light/lockable_spec.rb
|
271
80
|
- spec/stoplight/light/runnable_spec.rb
|
272
81
|
- spec/stoplight/light_spec.rb
|
273
82
|
- spec/stoplight/notifier/base_spec.rb
|
274
|
-
- spec/stoplight/notifier/bugsnag_spec.rb
|
275
83
|
- spec/stoplight/notifier/generic_spec.rb
|
276
|
-
- spec/stoplight/notifier/hip_chat_spec.rb
|
277
|
-
- spec/stoplight/notifier/honeybadger_spec.rb
|
278
84
|
- spec/stoplight/notifier/io_spec.rb
|
279
85
|
- spec/stoplight/notifier/logger_spec.rb
|
280
|
-
- spec/stoplight/notifier/pagerduty_spec.rb
|
281
|
-
- spec/stoplight/notifier/raven_spec.rb
|
282
|
-
- spec/stoplight/notifier/rollbar_spec.rb
|
283
|
-
- spec/stoplight/notifier/slack_spec.rb
|
284
86
|
- spec/stoplight/notifier_spec.rb
|
285
87
|
- spec/stoplight/state_spec.rb
|
286
88
|
- spec/stoplight/version_spec.rb
|
287
89
|
- spec/stoplight_spec.rb
|
90
|
+
- spec/support/configurable.rb
|
91
|
+
- spec/support/data_store/base.rb
|
92
|
+
- spec/support/data_store/base/clear_failures.rb
|
93
|
+
- spec/support/data_store/base/clear_state.rb
|
94
|
+
- spec/support/data_store/base/get_all.rb
|
95
|
+
- spec/support/data_store/base/get_failures.rb
|
96
|
+
- spec/support/data_store/base/get_state.rb
|
97
|
+
- spec/support/data_store/base/names.rb
|
98
|
+
- spec/support/data_store/base/record_failures.rb
|
99
|
+
- spec/support/data_store/base/set_state.rb
|
100
|
+
- spec/support/data_store/base/with_notification_lock.rb
|
101
|
+
- spec/support/database_cleaner.rb
|
102
|
+
- spec/support/exception_helpers.rb
|
103
|
+
- spec/support/light/runnable.rb
|
104
|
+
- spec/support/light/runnable/color.rb
|
105
|
+
- spec/support/light/runnable/run.rb
|
288
106
|
homepage: https://github.com/bolshakov/stoplight
|
289
107
|
licenses:
|
290
108
|
- MIT
|
@@ -297,20 +115,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
297
115
|
requirements:
|
298
116
|
- - ">="
|
299
117
|
- !ruby/object:Gem::Version
|
300
|
-
version:
|
118
|
+
version: 3.0.6
|
301
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
302
120
|
requirements:
|
303
121
|
- - ">="
|
304
122
|
- !ruby/object:Gem::Version
|
305
123
|
version: '0'
|
306
124
|
requirements: []
|
307
|
-
rubygems_version: 3.
|
125
|
+
rubygems_version: 3.3.7
|
308
126
|
signing_key:
|
309
127
|
specification_version: 4
|
310
128
|
summary: Traffic control for code.
|
311
129
|
test_files:
|
312
130
|
- spec/spec_helper.rb
|
131
|
+
- spec/stoplight/builder_spec.rb
|
132
|
+
- spec/stoplight/circuit_breaker_spec.rb
|
313
133
|
- spec/stoplight/color_spec.rb
|
134
|
+
- spec/stoplight/configurable_spec.rb
|
314
135
|
- spec/stoplight/data_store/base_spec.rb
|
315
136
|
- spec/stoplight/data_store/memory_spec.rb
|
316
137
|
- spec/stoplight/data_store/redis_spec.rb
|
@@ -318,20 +139,30 @@ test_files:
|
|
318
139
|
- spec/stoplight/default_spec.rb
|
319
140
|
- spec/stoplight/error_spec.rb
|
320
141
|
- spec/stoplight/failure_spec.rb
|
142
|
+
- spec/stoplight/light/lockable_spec.rb
|
321
143
|
- spec/stoplight/light/runnable_spec.rb
|
322
144
|
- spec/stoplight/light_spec.rb
|
323
145
|
- spec/stoplight/notifier/base_spec.rb
|
324
|
-
- spec/stoplight/notifier/bugsnag_spec.rb
|
325
146
|
- spec/stoplight/notifier/generic_spec.rb
|
326
|
-
- spec/stoplight/notifier/hip_chat_spec.rb
|
327
|
-
- spec/stoplight/notifier/honeybadger_spec.rb
|
328
147
|
- spec/stoplight/notifier/io_spec.rb
|
329
148
|
- spec/stoplight/notifier/logger_spec.rb
|
330
|
-
- spec/stoplight/notifier/pagerduty_spec.rb
|
331
|
-
- spec/stoplight/notifier/raven_spec.rb
|
332
|
-
- spec/stoplight/notifier/rollbar_spec.rb
|
333
|
-
- spec/stoplight/notifier/slack_spec.rb
|
334
149
|
- spec/stoplight/notifier_spec.rb
|
335
150
|
- spec/stoplight/state_spec.rb
|
336
151
|
- spec/stoplight/version_spec.rb
|
337
152
|
- spec/stoplight_spec.rb
|
153
|
+
- spec/support/configurable.rb
|
154
|
+
- spec/support/data_store/base/clear_failures.rb
|
155
|
+
- spec/support/data_store/base/clear_state.rb
|
156
|
+
- spec/support/data_store/base/get_all.rb
|
157
|
+
- spec/support/data_store/base/get_failures.rb
|
158
|
+
- spec/support/data_store/base/get_state.rb
|
159
|
+
- spec/support/data_store/base/names.rb
|
160
|
+
- spec/support/data_store/base/record_failures.rb
|
161
|
+
- spec/support/data_store/base/set_state.rb
|
162
|
+
- spec/support/data_store/base/with_notification_lock.rb
|
163
|
+
- spec/support/data_store/base.rb
|
164
|
+
- spec/support/database_cleaner.rb
|
165
|
+
- spec/support/exception_helpers.rb
|
166
|
+
- spec/support/light/runnable/color.rb
|
167
|
+
- spec/support/light/runnable/run.rb
|
168
|
+
- spec/support/light/runnable.rb
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Stoplight
|
4
|
-
module Notifier
|
5
|
-
# @see Base
|
6
|
-
class Bugsnag < Base
|
7
|
-
DEFAULT_OPTIONS = {
|
8
|
-
severity: 'info'
|
9
|
-
}.freeze
|
10
|
-
|
11
|
-
StoplightStatusChange = Class.new(Error::Base)
|
12
|
-
|
13
|
-
# @return [Proc]
|
14
|
-
attr_reader :formatter
|
15
|
-
# @return [::Bugsnag]
|
16
|
-
attr_reader :bugsnag
|
17
|
-
# @return [Hash{Symbol => Object}]
|
18
|
-
attr_reader :options
|
19
|
-
|
20
|
-
# @param bugsnag [::Bugsnag]
|
21
|
-
# @param formatter [Proc, nil]
|
22
|
-
# @param options [Hash{Symbol => Object}]
|
23
|
-
# @option options [String] :severity
|
24
|
-
def initialize(bugsnag, formatter = nil, options = {})
|
25
|
-
@bugsnag = bugsnag
|
26
|
-
@formatter = formatter || Default::FORMATTER
|
27
|
-
@options = DEFAULT_OPTIONS.merge(options)
|
28
|
-
end
|
29
|
-
|
30
|
-
def notify(light, from_color, to_color, error)
|
31
|
-
message = formatter.call(light, from_color, to_color, error)
|
32
|
-
bugsnag.notify(StoplightStatusChange.new(message), options)
|
33
|
-
message
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|