stoplight 4.0.0 → 4.1.0
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 +1 -4
- data/lib/stoplight/builder.rb +2 -0
- data/lib/stoplight/circuit_breaker.rb +10 -0
- 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/light/runnable/state.rb +31 -0
- data/spec/support/light/runnable.rb +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26a32d4e3aa3c515fb23a75f3055d250eaf10431eeae1316086bfe69ca569277
|
4
|
+
data.tar.gz: 9cfadd0dc4bbc99687aeffc847ae68b9926b29383530a2d55ae79ac2b22039b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ee973ed322845425185904de1d681064794d3a39e7d303c36b172b377d080541867e81df5cfc2a1a75da07b1088dcf15de61c807d446ca3d60582c1d645d07f
|
7
|
+
data.tar.gz: 16420c055193f5c9364d517ecea8d4ffb1ad9fbd184a77f792d1b693ab13b5d9040f56b53027c1cfcc53b971590cb7c4ffb215c2cf3692e6c978bb8f51d592b3
|
data/README.md
CHANGED
@@ -9,9 +9,6 @@ Stoplight is traffic control for code. It's an implementation of the circuit
|
|
9
9
|
breaker pattern in Ruby.
|
10
10
|
|
11
11
|
---
|
12
|
-
:warning: You're browsing the documentation of the not realized version. You can find the documentation
|
13
|
-
for the most recent version 3.0.1 [here](https://github.com/bolshakov/stoplight/tree/v3.0.1).
|
14
|
-
|
15
12
|
Does your code use unreliable systems, like a flaky database or a spotty web
|
16
13
|
service? Wrap calls to those up in stoplights to prevent them from affecting
|
17
14
|
the rest of your application.
|
@@ -38,7 +35,7 @@ Check out [stoplight-admin][] for controlling your stoplights.
|
|
38
35
|
- [Advanced Usage](#advanced-usage)
|
39
36
|
- [Locking](#locking)
|
40
37
|
- [Testing](#testing)
|
41
|
-
- [Maintenance Policy]
|
38
|
+
- [Maintenance Policy](#maintenance-policy)
|
42
39
|
- [Credits](#credits)
|
43
40
|
|
44
41
|
## Installation
|
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
|
@@ -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.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-20 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
|
@@ -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
|