stoplight 4.0.0 → 4.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 +4 -4
- data/README.md +5 -3
- data/lib/stoplight/builder.rb +2 -0
- data/lib/stoplight/circuit_breaker.rb +10 -0
- data/lib/stoplight/data_store/memory.rb +1 -1
- data/lib/stoplight/light/runnable.rb +6 -0
- data/lib/stoplight/version.rb +1 -1
- data/spec/stoplight/circuit_breaker_spec.rb +8 -0
- data/spec/stoplight/light/runnable_spec.rb +2 -0
- data/spec/support/data_store/base/clear_failures.rb +6 -0
- data/spec/support/light/runnable/state.rb +31 -0
- data/spec/support/light/runnable.rb +1 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dec6c43881dfde16456ffa319f2f543f2c507dbdd760c5adf7ddb155dfa9292b
|
4
|
+
data.tar.gz: b3609d6233f73d9a2c4a5474ef291d76fe9ccd906267cf9d831b22a040c67d1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 536ab89edb5ce429274c1f54f6718ac1a82968bb10a75a5c8d44b4dfacaf5a1a37a6f9aaac2c2c91f0b0849e149df6696e1d29373f40280ab860c3ada08e357f
|
7
|
+
data.tar.gz: b59267822e4ead10f8675e08c6fa16bf76c4b430a0c3c0fa9d69eb42a4df8387e22a36135b6c5d76a5f76b4e002db052937af311ee160b919a0c85a027341564
|
data/README.md
CHANGED
@@ -9,8 +9,9 @@ Stoplight is traffic control for code. It's an implementation of the circuit
|
|
9
9
|
breaker pattern in Ruby.
|
10
10
|
|
11
11
|
---
|
12
|
-
|
13
|
-
|
12
|
+
|
13
|
+
:warning:️ You're currently browsing the documentation for Stoplight 4.x. If you're looking for
|
14
|
+
the documentation of the previous version 3.x, you can find it [here](https://github.com/bolshakov/stoplight/tree/release/v3.x).
|
14
15
|
|
15
16
|
Does your code use unreliable systems, like a flaky database or a spotty web
|
16
17
|
service? Wrap calls to those up in stoplights to prevent them from affecting
|
@@ -38,7 +39,7 @@ Check out [stoplight-admin][] for controlling your stoplights.
|
|
38
39
|
- [Advanced Usage](#advanced-usage)
|
39
40
|
- [Locking](#locking)
|
40
41
|
- [Testing](#testing)
|
41
|
-
- [Maintenance Policy]
|
42
|
+
- [Maintenance Policy](#maintenance-policy)
|
42
43
|
- [Credits](#credits)
|
43
44
|
|
44
45
|
## Installation
|
@@ -360,6 +361,7 @@ Stoplight.default_notifiers += [notifier]
|
|
360
361
|
#### Community-supported Notifiers
|
361
362
|
|
362
363
|
* [stoplight-sentry]
|
364
|
+
* [stoplight-honeybadger](https://github.com/qoqa/stoplight-honeybadger)
|
363
365
|
|
364
366
|
You you want to implement your own notifier, the following section contains all the required information.
|
365
367
|
|
data/lib/stoplight/builder.rb
CHANGED
@@ -30,6 +30,8 @@ module Stoplight
|
|
30
30
|
def_delegator :build, :with_error_handler
|
31
31
|
def_delegator :build, :with_fallback
|
32
32
|
def_delegator :build, :color
|
33
|
+
def_delegator :build, :name
|
34
|
+
def_delegator :build, :state
|
33
35
|
def_delegator :build, :run
|
34
36
|
def_delegator :build, :lock
|
35
37
|
def_delegator :build, :unlock
|
@@ -39,6 +39,16 @@ module Stoplight
|
|
39
39
|
raise NotImplementedError
|
40
40
|
end
|
41
41
|
|
42
|
+
# @return [String] one of +locked_green+, +locked_red+, and +unlocked+
|
43
|
+
def state
|
44
|
+
raise NotImplementedError
|
45
|
+
end
|
46
|
+
|
47
|
+
# @return [String] the light's name
|
48
|
+
def name
|
49
|
+
raise NotImplementedError
|
50
|
+
end
|
51
|
+
|
42
52
|
# Returns current color:
|
43
53
|
# * +Stoplight::Color::GREEN+ -- circuit breaker is closed
|
44
54
|
# * +Stoplight::Color::RED+ -- circuit breaker is open
|
data/lib/stoplight/version.rb
CHANGED
@@ -21,6 +21,14 @@ RSpec.describe Stoplight::CircuitBreaker do
|
|
21
21
|
expect { circuit_breaker.color }.to raise_error(NotImplementedError)
|
22
22
|
end
|
23
23
|
|
24
|
+
specify '#state' do
|
25
|
+
expect { circuit_breaker.state }.to raise_error(NotImplementedError)
|
26
|
+
end
|
27
|
+
|
28
|
+
specify '#name' do
|
29
|
+
expect { circuit_breaker.name }.to raise_error(NotImplementedError)
|
30
|
+
end
|
31
|
+
|
24
32
|
specify '#run' do
|
25
33
|
expect { circuit_breaker.run {} }.to raise_error(NotImplementedError)
|
26
34
|
end
|
@@ -23,6 +23,7 @@ RSpec.describe Stoplight::Light::Runnable, :redis do
|
|
23
23
|
context 'with memory data store' do
|
24
24
|
let(:data_store) { Stoplight::DataStore::Memory.new }
|
25
25
|
|
26
|
+
it_behaves_like 'Stoplight::Light::Runnable#state'
|
26
27
|
it_behaves_like 'Stoplight::Light::Runnable#color'
|
27
28
|
it_behaves_like 'Stoplight::Light::Runnable#run'
|
28
29
|
end
|
@@ -30,6 +31,7 @@ RSpec.describe Stoplight::Light::Runnable, :redis do
|
|
30
31
|
context 'with redis data store', :redis do
|
31
32
|
let(:data_store) { Stoplight::DataStore::Redis.new(redis) }
|
32
33
|
|
34
|
+
it_behaves_like 'Stoplight::Light::Runnable#state'
|
33
35
|
it_behaves_like 'Stoplight::Light::Runnable#color'
|
34
36
|
it_behaves_like 'Stoplight::Light::Runnable#run'
|
35
37
|
end
|
@@ -9,6 +9,12 @@ RSpec.shared_examples 'Stoplight::DataStore::Base#clear_failures' do
|
|
9
9
|
expect(data_store.clear_failures(light)).to contain_exactly(failure)
|
10
10
|
end
|
11
11
|
|
12
|
+
it 'returns an empty array when there are no failures' do
|
13
|
+
data_store.clear_failures(light)
|
14
|
+
|
15
|
+
expect(data_store.clear_failures(light)).to be_empty
|
16
|
+
end
|
17
|
+
|
12
18
|
it 'clears the failures' do
|
13
19
|
expect do
|
14
20
|
data_store.clear_failures(light)
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.shared_examples 'Stoplight::Light::Runnable#state' do
|
4
|
+
subject(:light) { Stoplight::Light.new(name) }
|
5
|
+
|
6
|
+
let(:name) { random_string }
|
7
|
+
|
8
|
+
it 'is initially unlocked' do
|
9
|
+
expect(light.state).to eql(Stoplight::State::UNLOCKED)
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'when its locked green' do
|
13
|
+
before do
|
14
|
+
light.data_store.set_state(light, Stoplight::State::LOCKED_GREEN)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'is locked green' do
|
18
|
+
expect(light.state).to eql(Stoplight::State::LOCKED_GREEN)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'when its locked red' do
|
23
|
+
before do
|
24
|
+
light.data_store.set_state(light, Stoplight::State::LOCKED_RED)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'is locked red' do
|
28
|
+
expect(light.state).to eql(Stoplight::State::LOCKED_RED)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
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.
|
4
|
+
version: 4.1.1
|
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:
|
13
|
+
date: 2025-02-08 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: redlock
|
@@ -103,6 +103,7 @@ files:
|
|
103
103
|
- spec/support/light/runnable.rb
|
104
104
|
- spec/support/light/runnable/color.rb
|
105
105
|
- spec/support/light/runnable/run.rb
|
106
|
+
- spec/support/light/runnable/state.rb
|
106
107
|
homepage: https://github.com/bolshakov/stoplight
|
107
108
|
licenses:
|
108
109
|
- MIT
|
@@ -122,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
123
|
- !ruby/object:Gem::Version
|
123
124
|
version: '0'
|
124
125
|
requirements: []
|
125
|
-
rubygems_version: 3.
|
126
|
+
rubygems_version: 3.5.18
|
126
127
|
signing_key:
|
127
128
|
specification_version: 4
|
128
129
|
summary: Traffic control for code.
|
@@ -165,4 +166,5 @@ test_files:
|
|
165
166
|
- spec/support/exception_helpers.rb
|
166
167
|
- spec/support/light/runnable/color.rb
|
167
168
|
- spec/support/light/runnable/run.rb
|
169
|
+
- spec/support/light/runnable/state.rb
|
168
170
|
- spec/support/light/runnable.rb
|