stoplight 3.0.2 → 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 -180
- 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/memory.rb +20 -5
- data/lib/stoplight/data_store/redis.rb +37 -5
- 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 +25 -24
- 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 +32 -8
- 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/memory_spec.rb +12 -149
- data/spec/stoplight/data_store/redis_spec.rb +26 -158
- 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 -273
- 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 +51 -231
- data/lib/stoplight/notifier/bugsnag.rb +0 -37
- 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/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
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,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-08-
|
13
|
+
date: 2023-08-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: redlock
|
@@ -26,216 +26,6 @@ dependencies:
|
|
26
26
|
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: '1.0'
|
29
|
-
- !ruby/object:Gem::Dependency
|
30
|
-
name: benchmark-ips
|
31
|
-
requirement: !ruby/object:Gem::Requirement
|
32
|
-
requirements:
|
33
|
-
- - "~>"
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version: '2.3'
|
36
|
-
type: :development
|
37
|
-
prerelease: false
|
38
|
-
version_requirements: !ruby/object:Gem::Requirement
|
39
|
-
requirements:
|
40
|
-
- - "~>"
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: '2.3'
|
43
|
-
- !ruby/object:Gem::Dependency
|
44
|
-
name: bugsnag
|
45
|
-
requirement: !ruby/object:Gem::Requirement
|
46
|
-
requirements:
|
47
|
-
- - "~>"
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: '4.0'
|
50
|
-
type: :development
|
51
|
-
prerelease: false
|
52
|
-
version_requirements: !ruby/object:Gem::Requirement
|
53
|
-
requirements:
|
54
|
-
- - "~>"
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version: '4.0'
|
57
|
-
- !ruby/object:Gem::Dependency
|
58
|
-
name: fakeredis
|
59
|
-
requirement: !ruby/object:Gem::Requirement
|
60
|
-
requirements:
|
61
|
-
- - "~>"
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
version: '0.8'
|
64
|
-
type: :development
|
65
|
-
prerelease: false
|
66
|
-
version_requirements: !ruby/object:Gem::Requirement
|
67
|
-
requirements:
|
68
|
-
- - "~>"
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
version: '0.8'
|
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: mock_redis
|
87
|
-
requirement: !ruby/object:Gem::Requirement
|
88
|
-
requirements:
|
89
|
-
- - "~>"
|
90
|
-
- !ruby/object:Gem::Version
|
91
|
-
version: '0.3'
|
92
|
-
type: :development
|
93
|
-
prerelease: false
|
94
|
-
version_requirements: !ruby/object:Gem::Requirement
|
95
|
-
requirements:
|
96
|
-
- - "~>"
|
97
|
-
- !ruby/object:Gem::Version
|
98
|
-
version: '0.3'
|
99
|
-
- !ruby/object:Gem::Dependency
|
100
|
-
name: pagerduty
|
101
|
-
requirement: !ruby/object:Gem::Requirement
|
102
|
-
requirements:
|
103
|
-
- - "~>"
|
104
|
-
- !ruby/object:Gem::Version
|
105
|
-
version: 2.1.1
|
106
|
-
type: :development
|
107
|
-
prerelease: false
|
108
|
-
version_requirements: !ruby/object:Gem::Requirement
|
109
|
-
requirements:
|
110
|
-
- - "~>"
|
111
|
-
- !ruby/object:Gem::Version
|
112
|
-
version: 2.1.1
|
113
|
-
- !ruby/object:Gem::Dependency
|
114
|
-
name: rake
|
115
|
-
requirement: !ruby/object:Gem::Requirement
|
116
|
-
requirements:
|
117
|
-
- - "~>"
|
118
|
-
- !ruby/object:Gem::Version
|
119
|
-
version: '13.0'
|
120
|
-
type: :development
|
121
|
-
prerelease: false
|
122
|
-
version_requirements: !ruby/object:Gem::Requirement
|
123
|
-
requirements:
|
124
|
-
- - "~>"
|
125
|
-
- !ruby/object:Gem::Version
|
126
|
-
version: '13.0'
|
127
|
-
- !ruby/object:Gem::Dependency
|
128
|
-
name: redis
|
129
|
-
requirement: !ruby/object:Gem::Requirement
|
130
|
-
requirements:
|
131
|
-
- - "~>"
|
132
|
-
- !ruby/object:Gem::Version
|
133
|
-
version: '4.1'
|
134
|
-
type: :development
|
135
|
-
prerelease: false
|
136
|
-
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
requirements:
|
138
|
-
- - "~>"
|
139
|
-
- !ruby/object:Gem::Version
|
140
|
-
version: '4.1'
|
141
|
-
- !ruby/object:Gem::Dependency
|
142
|
-
name: rspec
|
143
|
-
requirement: !ruby/object:Gem::Requirement
|
144
|
-
requirements:
|
145
|
-
- - "~>"
|
146
|
-
- !ruby/object:Gem::Version
|
147
|
-
version: '3.11'
|
148
|
-
type: :development
|
149
|
-
prerelease: false
|
150
|
-
version_requirements: !ruby/object:Gem::Requirement
|
151
|
-
requirements:
|
152
|
-
- - "~>"
|
153
|
-
- !ruby/object:Gem::Version
|
154
|
-
version: '3.11'
|
155
|
-
- !ruby/object:Gem::Dependency
|
156
|
-
name: rubocop
|
157
|
-
requirement: !ruby/object:Gem::Requirement
|
158
|
-
requirements:
|
159
|
-
- - "~>"
|
160
|
-
- !ruby/object:Gem::Version
|
161
|
-
version: 1.0.0
|
162
|
-
type: :development
|
163
|
-
prerelease: false
|
164
|
-
version_requirements: !ruby/object:Gem::Requirement
|
165
|
-
requirements:
|
166
|
-
- - "~>"
|
167
|
-
- !ruby/object:Gem::Version
|
168
|
-
version: 1.0.0
|
169
|
-
- !ruby/object:Gem::Dependency
|
170
|
-
name: sentry-raven
|
171
|
-
requirement: !ruby/object:Gem::Requirement
|
172
|
-
requirements:
|
173
|
-
- - "~>"
|
174
|
-
- !ruby/object:Gem::Version
|
175
|
-
version: '1.2'
|
176
|
-
type: :development
|
177
|
-
prerelease: false
|
178
|
-
version_requirements: !ruby/object:Gem::Requirement
|
179
|
-
requirements:
|
180
|
-
- - "~>"
|
181
|
-
- !ruby/object:Gem::Version
|
182
|
-
version: '1.2'
|
183
|
-
- !ruby/object:Gem::Dependency
|
184
|
-
name: simplecov
|
185
|
-
requirement: !ruby/object:Gem::Requirement
|
186
|
-
requirements:
|
187
|
-
- - "~>"
|
188
|
-
- !ruby/object:Gem::Version
|
189
|
-
version: '0.21'
|
190
|
-
type: :development
|
191
|
-
prerelease: false
|
192
|
-
version_requirements: !ruby/object:Gem::Requirement
|
193
|
-
requirements:
|
194
|
-
- - "~>"
|
195
|
-
- !ruby/object:Gem::Version
|
196
|
-
version: '0.21'
|
197
|
-
- !ruby/object:Gem::Dependency
|
198
|
-
name: simplecov-lcov
|
199
|
-
requirement: !ruby/object:Gem::Requirement
|
200
|
-
requirements:
|
201
|
-
- - "~>"
|
202
|
-
- !ruby/object:Gem::Version
|
203
|
-
version: '0.8'
|
204
|
-
type: :development
|
205
|
-
prerelease: false
|
206
|
-
version_requirements: !ruby/object:Gem::Requirement
|
207
|
-
requirements:
|
208
|
-
- - "~>"
|
209
|
-
- !ruby/object:Gem::Version
|
210
|
-
version: '0.8'
|
211
|
-
- !ruby/object:Gem::Dependency
|
212
|
-
name: slack-notifier
|
213
|
-
requirement: !ruby/object:Gem::Requirement
|
214
|
-
requirements:
|
215
|
-
- - "~>"
|
216
|
-
- !ruby/object:Gem::Version
|
217
|
-
version: '1.3'
|
218
|
-
type: :development
|
219
|
-
prerelease: false
|
220
|
-
version_requirements: !ruby/object:Gem::Requirement
|
221
|
-
requirements:
|
222
|
-
- - "~>"
|
223
|
-
- !ruby/object:Gem::Version
|
224
|
-
version: '1.3'
|
225
|
-
- !ruby/object:Gem::Dependency
|
226
|
-
name: timecop
|
227
|
-
requirement: !ruby/object:Gem::Requirement
|
228
|
-
requirements:
|
229
|
-
- - "~>"
|
230
|
-
- !ruby/object:Gem::Version
|
231
|
-
version: '0.9'
|
232
|
-
type: :development
|
233
|
-
prerelease: false
|
234
|
-
version_requirements: !ruby/object:Gem::Requirement
|
235
|
-
requirements:
|
236
|
-
- - "~>"
|
237
|
-
- !ruby/object:Gem::Version
|
238
|
-
version: '0.9'
|
239
29
|
description: An implementation of the circuit breaker pattern.
|
240
30
|
email:
|
241
31
|
- camdez@gmail.com
|
@@ -249,7 +39,11 @@ files:
|
|
249
39
|
- LICENSE.md
|
250
40
|
- README.md
|
251
41
|
- lib/stoplight.rb
|
42
|
+
- lib/stoplight/builder.rb
|
43
|
+
- lib/stoplight/circuit_breaker.rb
|
252
44
|
- lib/stoplight/color.rb
|
45
|
+
- lib/stoplight/configurable.rb
|
46
|
+
- lib/stoplight/configuration.rb
|
253
47
|
- lib/stoplight/data_store.rb
|
254
48
|
- lib/stoplight/data_store/base.rb
|
255
49
|
- lib/stoplight/data_store/memory.rb
|
@@ -258,22 +52,23 @@ files:
|
|
258
52
|
- lib/stoplight/error.rb
|
259
53
|
- lib/stoplight/failure.rb
|
260
54
|
- lib/stoplight/light.rb
|
55
|
+
- lib/stoplight/light/deprecated.rb
|
56
|
+
- lib/stoplight/light/lockable.rb
|
261
57
|
- lib/stoplight/light/runnable.rb
|
262
58
|
- lib/stoplight/notifier.rb
|
263
59
|
- lib/stoplight/notifier/base.rb
|
264
|
-
- lib/stoplight/notifier/bugsnag.rb
|
265
60
|
- lib/stoplight/notifier/generic.rb
|
266
|
-
- lib/stoplight/notifier/honeybadger.rb
|
267
61
|
- lib/stoplight/notifier/io.rb
|
268
62
|
- lib/stoplight/notifier/logger.rb
|
269
|
-
- lib/stoplight/
|
270
|
-
- lib/stoplight/
|
271
|
-
- lib/stoplight/notifier/rollbar.rb
|
272
|
-
- lib/stoplight/notifier/slack.rb
|
63
|
+
- lib/stoplight/rspec.rb
|
64
|
+
- lib/stoplight/rspec/generic_notifier.rb
|
273
65
|
- lib/stoplight/state.rb
|
274
66
|
- lib/stoplight/version.rb
|
275
67
|
- spec/spec_helper.rb
|
68
|
+
- spec/stoplight/builder_spec.rb
|
69
|
+
- spec/stoplight/circuit_breaker_spec.rb
|
276
70
|
- spec/stoplight/color_spec.rb
|
71
|
+
- spec/stoplight/configurable_spec.rb
|
277
72
|
- spec/stoplight/data_store/base_spec.rb
|
278
73
|
- spec/stoplight/data_store/memory_spec.rb
|
279
74
|
- spec/stoplight/data_store/redis_spec.rb
|
@@ -281,22 +76,33 @@ files:
|
|
281
76
|
- spec/stoplight/default_spec.rb
|
282
77
|
- spec/stoplight/error_spec.rb
|
283
78
|
- spec/stoplight/failure_spec.rb
|
79
|
+
- spec/stoplight/light/lockable_spec.rb
|
284
80
|
- spec/stoplight/light/runnable_spec.rb
|
285
81
|
- spec/stoplight/light_spec.rb
|
286
82
|
- spec/stoplight/notifier/base_spec.rb
|
287
|
-
- spec/stoplight/notifier/bugsnag_spec.rb
|
288
83
|
- spec/stoplight/notifier/generic_spec.rb
|
289
|
-
- spec/stoplight/notifier/honeybadger_spec.rb
|
290
84
|
- spec/stoplight/notifier/io_spec.rb
|
291
85
|
- spec/stoplight/notifier/logger_spec.rb
|
292
|
-
- spec/stoplight/notifier/pagerduty_spec.rb
|
293
|
-
- spec/stoplight/notifier/raven_spec.rb
|
294
|
-
- spec/stoplight/notifier/rollbar_spec.rb
|
295
|
-
- spec/stoplight/notifier/slack_spec.rb
|
296
86
|
- spec/stoplight/notifier_spec.rb
|
297
87
|
- spec/stoplight/state_spec.rb
|
298
88
|
- spec/stoplight/version_spec.rb
|
299
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
|
300
106
|
homepage: https://github.com/bolshakov/stoplight
|
301
107
|
licenses:
|
302
108
|
- MIT
|
@@ -309,7 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
309
115
|
requirements:
|
310
116
|
- - ">="
|
311
117
|
- !ruby/object:Gem::Version
|
312
|
-
version:
|
118
|
+
version: 3.0.6
|
313
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
314
120
|
requirements:
|
315
121
|
- - ">="
|
@@ -322,7 +128,10 @@ specification_version: 4
|
|
322
128
|
summary: Traffic control for code.
|
323
129
|
test_files:
|
324
130
|
- spec/spec_helper.rb
|
131
|
+
- spec/stoplight/builder_spec.rb
|
132
|
+
- spec/stoplight/circuit_breaker_spec.rb
|
325
133
|
- spec/stoplight/color_spec.rb
|
134
|
+
- spec/stoplight/configurable_spec.rb
|
326
135
|
- spec/stoplight/data_store/base_spec.rb
|
327
136
|
- spec/stoplight/data_store/memory_spec.rb
|
328
137
|
- spec/stoplight/data_store/redis_spec.rb
|
@@ -330,19 +139,30 @@ test_files:
|
|
330
139
|
- spec/stoplight/default_spec.rb
|
331
140
|
- spec/stoplight/error_spec.rb
|
332
141
|
- spec/stoplight/failure_spec.rb
|
142
|
+
- spec/stoplight/light/lockable_spec.rb
|
333
143
|
- spec/stoplight/light/runnable_spec.rb
|
334
144
|
- spec/stoplight/light_spec.rb
|
335
145
|
- spec/stoplight/notifier/base_spec.rb
|
336
|
-
- spec/stoplight/notifier/bugsnag_spec.rb
|
337
146
|
- spec/stoplight/notifier/generic_spec.rb
|
338
|
-
- spec/stoplight/notifier/honeybadger_spec.rb
|
339
147
|
- spec/stoplight/notifier/io_spec.rb
|
340
148
|
- spec/stoplight/notifier/logger_spec.rb
|
341
|
-
- spec/stoplight/notifier/pagerduty_spec.rb
|
342
|
-
- spec/stoplight/notifier/raven_spec.rb
|
343
|
-
- spec/stoplight/notifier/rollbar_spec.rb
|
344
|
-
- spec/stoplight/notifier/slack_spec.rb
|
345
149
|
- spec/stoplight/notifier_spec.rb
|
346
150
|
- spec/stoplight/state_spec.rb
|
347
151
|
- spec/stoplight/version_spec.rb
|
348
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
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Stoplight
|
4
|
-
module Notifier
|
5
|
-
# @see Base
|
6
|
-
class Honeybadger < Base
|
7
|
-
DEFAULT_OPTIONS = {
|
8
|
-
parameters: {},
|
9
|
-
session: {},
|
10
|
-
context: {}
|
11
|
-
}.freeze
|
12
|
-
|
13
|
-
# @return [String]
|
14
|
-
attr_reader :api_key
|
15
|
-
# @return [Proc]
|
16
|
-
attr_reader :formatter
|
17
|
-
# @return [Hash{Symbol => Object}]
|
18
|
-
attr_reader :options
|
19
|
-
|
20
|
-
# @param api_key [String]
|
21
|
-
# @param formatter [Proc, nil]
|
22
|
-
# @param options [Hash{Symbol => Object}]
|
23
|
-
# @option options [Hash] :parameters
|
24
|
-
# @option options [Hash] :session
|
25
|
-
# @option options [Hash] :context
|
26
|
-
def initialize(api_key, formatter = nil, options = {})
|
27
|
-
@api_key = api_key
|
28
|
-
@formatter = formatter || Default::FORMATTER
|
29
|
-
@options = DEFAULT_OPTIONS.merge(options)
|
30
|
-
end
|
31
|
-
|
32
|
-
def notify(light, from_color, to_color, error)
|
33
|
-
message = formatter.call(light, from_color, to_color, error)
|
34
|
-
h = options.merge(
|
35
|
-
api_key: api_key,
|
36
|
-
error_message: message,
|
37
|
-
backtrace: error&.backtrace
|
38
|
-
)
|
39
|
-
::Honeybadger.notify(h)
|
40
|
-
message
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Stoplight
|
4
|
-
module Notifier
|
5
|
-
# @see Base
|
6
|
-
class Pagerduty < Base
|
7
|
-
include Generic
|
8
|
-
|
9
|
-
# @return [::Pagerduty]
|
10
|
-
def pagerduty
|
11
|
-
@object
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def put(message)
|
17
|
-
pagerduty.trigger(message)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Stoplight
|
4
|
-
module Notifier
|
5
|
-
# @see Base
|
6
|
-
class Raven < Base
|
7
|
-
DEFAULT_OPTIONS = {
|
8
|
-
extra: {}
|
9
|
-
}.freeze
|
10
|
-
|
11
|
-
# @return [::Raven::Configuration]
|
12
|
-
attr_reader :configuration
|
13
|
-
# @return [Proc]
|
14
|
-
attr_reader :formatter
|
15
|
-
# @return [Hash{Symbol => Object}]
|
16
|
-
attr_reader :options
|
17
|
-
|
18
|
-
# @param api_key [String]
|
19
|
-
# @param formatter [Proc, nil]
|
20
|
-
# @param options [Hash{Symbol => Object}]
|
21
|
-
# @option options [Hash] :extra
|
22
|
-
def initialize(configuration, formatter = nil, options = {})
|
23
|
-
@configuration = configuration
|
24
|
-
@formatter = formatter || Default::FORMATTER
|
25
|
-
@options = DEFAULT_OPTIONS.merge(options)
|
26
|
-
end
|
27
|
-
|
28
|
-
def notify(light, from_color, to_color, error)
|
29
|
-
message = formatter.call(light, from_color, to_color, error)
|
30
|
-
|
31
|
-
h = options.merge(
|
32
|
-
configuration: configuration,
|
33
|
-
backtrace: error&.backtrace
|
34
|
-
)
|
35
|
-
::Raven.capture_message(message, h)
|
36
|
-
message
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Stoplight
|
4
|
-
module Notifier
|
5
|
-
# @see Base
|
6
|
-
class Rollbar < 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 [::Rollbar]
|
16
|
-
attr_reader :rollbar
|
17
|
-
# @return [Hash{Symbol => Object}]
|
18
|
-
attr_reader :options
|
19
|
-
|
20
|
-
# @param rollbar [::Rollbar]
|
21
|
-
# @param formatter [Proc, nil]
|
22
|
-
# @param options [Hash{Symbol => Object}]
|
23
|
-
# @option options [String] :severity
|
24
|
-
def initialize(rollbar, formatter = nil, options = {})
|
25
|
-
@rollbar = rollbar
|
26
|
-
@formatter = formatter || Default::FORMATTER
|
27
|
-
@options = DEFAULT_OPTIONS.merge(options)
|
28
|
-
end
|
29
|
-
|
30
|
-
def notify(light, from_color, to_color, error)
|
31
|
-
formatter.call(light, from_color, to_color, error).tap do |message|
|
32
|
-
severity = options.fetch(:severity)
|
33
|
-
exception = StoplightStatusChange.new(message)
|
34
|
-
rollbar.__send__(severity, exception)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Stoplight
|
4
|
-
module Notifier
|
5
|
-
# @see Base
|
6
|
-
class Slack < Base
|
7
|
-
include Generic
|
8
|
-
|
9
|
-
# @return [::Slack::Notifier]
|
10
|
-
def slack
|
11
|
-
@object
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def put(message)
|
17
|
-
slack.ping(message)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,90 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
# require 'bugsnag'
|
6
|
-
module Bugsnag
|
7
|
-
end
|
8
|
-
|
9
|
-
RSpec.describe Stoplight::Notifier::Bugsnag do
|
10
|
-
it 'is a class' do
|
11
|
-
expect(described_class).to be_a(Class)
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'is a subclass of Base' do
|
15
|
-
expect(described_class).to be < Stoplight::Notifier::Base
|
16
|
-
end
|
17
|
-
|
18
|
-
describe '#formatter' do
|
19
|
-
it 'is initially the default' do
|
20
|
-
expect(described_class.new(nil, nil).formatter)
|
21
|
-
.to eql(Stoplight::Default::FORMATTER)
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'reads the formatter' do
|
25
|
-
formatter = proc {}
|
26
|
-
expect(described_class.new(nil, formatter).formatter)
|
27
|
-
.to eql(formatter)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe '#options' do
|
32
|
-
it 'is initially the default' do
|
33
|
-
expect(described_class.new(nil, nil).options)
|
34
|
-
.to eql(Stoplight::Notifier::Bugsnag::DEFAULT_OPTIONS)
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'reads the options' do
|
38
|
-
options = { key: :value }
|
39
|
-
expect(described_class.new(nil, nil, options).options)
|
40
|
-
.to eql(Stoplight::Notifier::Bugsnag::DEFAULT_OPTIONS.merge(options))
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe '#bugsnag' do
|
45
|
-
it 'reads the Bugsnag client' do
|
46
|
-
client = Bugsnag
|
47
|
-
expect(described_class.new(client, nil).bugsnag)
|
48
|
-
.to eql(client)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
describe '#notify' do
|
53
|
-
let(:light) { Stoplight::Light.new(name, &code) }
|
54
|
-
let(:name) { ('a'..'z').to_a.shuffle.join }
|
55
|
-
let(:code) { -> {} }
|
56
|
-
let(:from_color) { Stoplight::Color::GREEN }
|
57
|
-
let(:to_color) { Stoplight::Color::RED }
|
58
|
-
let(:notifier) { described_class.new(bugsnag) }
|
59
|
-
let(:bugsnag) { Bugsnag }
|
60
|
-
|
61
|
-
subject(:result) do
|
62
|
-
notifier.notify(light, from_color, to_color, error)
|
63
|
-
end
|
64
|
-
|
65
|
-
before do
|
66
|
-
status_change = described_class::StoplightStatusChange.new(message)
|
67
|
-
expect(bugsnag).to receive(:notify).with(status_change, severity: 'info')
|
68
|
-
end
|
69
|
-
|
70
|
-
context 'when no error given' do
|
71
|
-
let(:error) { nil }
|
72
|
-
|
73
|
-
it 'logs message' do
|
74
|
-
expect(result).to eq(message)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
context 'when message with an error given' do
|
79
|
-
let(:error) { ZeroDivisionError.new('divided by 0') }
|
80
|
-
|
81
|
-
it 'logs message' do
|
82
|
-
expect(result).to eq(message)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def message
|
87
|
-
notifier.formatter.call(light, from_color, to_color, error)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|