stoplight 6.0.0.rc3 → 6.0.0.rc5
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 +3 -3
- data/UPGRADING.md +9 -0
- data/lib/stoplight/infrastructure/redis/storage/state/state_snapshot.lua +9 -0
- data/lib/stoplight/infrastructure/redis/storage/state/transition_to_red.lua +2 -1
- data/lib/stoplight/infrastructure/redis/storage/state.rb +8 -8
- data/lib/stoplight/infrastructure/redis/storage/window_metrics/_evict.lua +4 -3
- data/lib/stoplight/version.rb +1 -1
- data/sig/stoplight/infrastructure/redis/storage/state.rbs +2 -2
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ade3c17bdafebab88e87b0f967dcf71a3fef99bb486c10a328e5110c4a4f456a
|
|
4
|
+
data.tar.gz: 2dff3cb5d7731a337c8d558c73d7a3091b7bf1bafb060ae7d8bd74d570f2b4c2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bd236321933ab75c09c468c3a12fddefe3002ce16cbfc7c6a28580d56fb3b6cace531792e9e5c0cae393158f5ba0ce6d62ec1425363bf4ba83abd8b6d4cb04ee
|
|
7
|
+
data.tar.gz: ce3c272066f30882c34921144dbe48773fd6ed4812d6933ea96842a0848830c4e9e5b1f23b46d7d93556c87d56cb6b7345553c06135ab54f2111f21a52aac759
|
data/README.md
CHANGED
|
@@ -678,8 +678,8 @@ Example: "Ruby 3.3 reaches end-of-life in March 2027, so Stoplight 7.0 will requ
|
|
|
678
678
|
## Development
|
|
679
679
|
|
|
680
680
|
After checking out the repo, run `bundle install` to install dependencies. Run tests with `bundle exec rspec` and check
|
|
681
|
-
code style with `bundle exec standardrb`.
|
|
682
|
-
|
|
681
|
+
code style with `bundle exec standardrb`. All work happens on `main` - see [CONTRIBUTING.md] for branch naming,
|
|
682
|
+
releases, and the contribution workflow.
|
|
683
683
|
|
|
684
684
|
## Credits
|
|
685
685
|
|
|
@@ -708,7 +708,7 @@ Fowler’s [CircuitBreaker][] article.
|
|
|
708
708
|
[complete list of contributors]: https://github.com/bolshakov/stoplight/graphs/contributors
|
|
709
709
|
[CircuitBreaker]: http://martinfowler.com/bliki/CircuitBreaker.html
|
|
710
710
|
[Redis]: https://redis.io/
|
|
711
|
-
[
|
|
711
|
+
[CONTRIBUTING.md]: CONTRIBUTING.md
|
|
712
712
|
[Valkey]: https://valkey.io/
|
|
713
713
|
[Ruby Maintenance Branches]: https://www.ruby-lang.org/en/downloads/branches/
|
|
714
714
|
[Redis's support policy]: https://redis.io/about/releases/
|
data/UPGRADING.md
CHANGED
|
@@ -8,6 +8,7 @@ Here's what you'll want to tackle during your upgrade, roughly ordered from the
|
|
|
8
8
|
|
|
9
9
|
- [ ] Make every `Stoplight("name", ...)` call site for the same name pass identical settings
|
|
10
10
|
- [ ] Move `data_store`, `notifiers`, and `error_notifier` from individual lights to `Stoplight.configure`
|
|
11
|
+
- [ ] Make sure that you run at least Ruby 3.3+, Redis 7.4+ (or Valkey 7.2+)
|
|
11
12
|
- [ ] Replace the `with_*` builder methods with settings passed at creation time
|
|
12
13
|
- [ ] Replace proc and anonymous-class error matchers with named classes or modules
|
|
13
14
|
- [ ] Account for Stoplight state reset after deployment
|
|
@@ -87,6 +88,13 @@ end
|
|
|
87
88
|
If you genuinely need more than one data store - separate Redis instances per tenant, for example - use named
|
|
88
89
|
systems, which own their own infrastructure. See [Systems: Namespace Isolation & Configuration][systems] for setup.
|
|
89
90
|
|
|
91
|
+
### Ruby 3.3 and Redis 7.4 Are the new Minimum
|
|
92
|
+
|
|
93
|
+
Stoplight 6 requires Ruby 3.3 or newer.
|
|
94
|
+
We also require Redis 7.4 or newer and Valkey 7.2 or newer and no longer tested or supported earlier versions.
|
|
95
|
+
|
|
96
|
+
See the [maintenance policy] for the versions under test.
|
|
97
|
+
|
|
90
98
|
### The Light Builder API Is Gone
|
|
91
99
|
|
|
92
100
|
`Light#with` and the whole `with_*` family are removed: `with_data_store`, `with_cool_off_time`, `with_threshold`,
|
|
@@ -582,6 +590,7 @@ Nothing. Stoplight will function as usual.
|
|
|
582
590
|
[Community-supported notifiers]: https://github.com/bolshakov/stoplight/tree/master#community-supported-notifiers
|
|
583
591
|
[How to implement your own notifier?]: https://github.com/bolshakov/stoplight/blob/master/lib/stoplight/notifier/generic.rb
|
|
584
592
|
[dropped notifiers]: https://github.com/bolshakov/stoplight/tree/v3.0.1/lib/stoplight/notifier
|
|
593
|
+
[maintenance policy]: https://github.com/bolshakov/stoplight#maintenance-policy
|
|
585
594
|
[without passing an empty block]: https://github.com/bolshakov/stoplight-admin/blob/9c9848eb94410e46b20972548f0863db224cb6da/lib/sinatra/stoplight_admin.rb#L30
|
|
586
595
|
[sliding window]: https://github.com/bolshakov/stoplight#custom-window-size
|
|
587
596
|
[systems]: https://github.com/bolshakov/stoplight/blob/master/docs/systems.md
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
-- @include now
|
|
2
2
|
|
|
3
3
|
local meta_key = KEYS[1]
|
|
4
|
-
local
|
|
4
|
+
local cool_off_time = tonumber(ARGV[1])
|
|
5
5
|
local current_ts = now() / 1000
|
|
6
|
+
local recovery_scheduled_after_ts = current_ts + cool_off_time
|
|
6
7
|
|
|
7
8
|
-- 1 if the field is a new field in the hash and the value was set
|
|
8
9
|
local became_red = redis.call('HSETNX', meta_key, 'breached_at', current_ts)
|
|
@@ -57,16 +57,19 @@ module Stoplight
|
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
def state_snapshot
|
|
60
|
-
breached_at_raw, locked_state, recovery_scheduled_after_raw, recovery_started_at_raw =
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
breached_at_raw, locked_state, recovery_scheduled_after_raw, recovery_started_at_raw, now_ms =
|
|
61
|
+
scripting.call(
|
|
62
|
+
"state/state_snapshot",
|
|
63
|
+
args: [],
|
|
64
|
+
keys: [state_key]
|
|
65
|
+
)
|
|
63
66
|
|
|
64
67
|
Domain::StateSnapshot.new(
|
|
65
68
|
breached_at: breached_at_raw && clock.at(breached_at_raw.to_f),
|
|
66
69
|
locked_state: locked_state&.to_sym || Stoplight::State::UNLOCKED,
|
|
67
70
|
recovery_scheduled_after: recovery_scheduled_after_raw && clock.at(recovery_scheduled_after_raw.to_f),
|
|
68
71
|
recovery_started_at: recovery_started_at_raw && clock.at(recovery_started_at_raw.to_f),
|
|
69
|
-
time: clock.
|
|
72
|
+
time: clock.at(now_ms.fdiv(1000))
|
|
70
73
|
)
|
|
71
74
|
end
|
|
72
75
|
|
|
@@ -123,12 +126,9 @@ module Stoplight
|
|
|
123
126
|
# Transitions to RED state and ensures only one notification
|
|
124
127
|
#
|
|
125
128
|
def transition_to_red
|
|
126
|
-
current_ts = clock.current_time.to_f
|
|
127
|
-
recovery_scheduled_after_ts = current_ts + cool_off_time
|
|
128
|
-
|
|
129
129
|
became_red = scripting.call(
|
|
130
130
|
"state/transition_to_red",
|
|
131
|
-
args: [
|
|
131
|
+
args: [cool_off_time],
|
|
132
132
|
keys: [state_key]
|
|
133
133
|
)
|
|
134
134
|
|
|
@@ -18,6 +18,8 @@ local function evict_buckets(metrics_key, ts_index_key, window_start)
|
|
|
18
18
|
return
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
+
local failures, successes = 0, 0
|
|
22
|
+
|
|
21
23
|
for from = 1, #buckets, EVICT_BATCH_SIZE do
|
|
22
24
|
local to = math.min(from + EVICT_BATCH_SIZE - 1, #buckets)
|
|
23
25
|
|
|
@@ -29,16 +31,15 @@ local function evict_buckets(metrics_key, ts_index_key, window_start)
|
|
|
29
31
|
|
|
30
32
|
local values = redis.call('HMGET', metrics_key, unpack(fields))
|
|
31
33
|
|
|
32
|
-
local failures, successes = 0, 0
|
|
33
34
|
for i = 1, #values, 2 do
|
|
34
35
|
failures = failures + (tonumber(values[i]) or 0)
|
|
35
36
|
successes = successes + (tonumber(values[i + 1]) or 0)
|
|
36
37
|
end
|
|
37
38
|
|
|
38
|
-
redis.call('HINCRBY', metrics_key, 'total_failures', -failures)
|
|
39
|
-
redis.call('HINCRBY', metrics_key, 'total_successes', -successes)
|
|
40
39
|
redis.call('HDEL', metrics_key, unpack(fields))
|
|
41
40
|
end
|
|
42
41
|
|
|
42
|
+
redis.call('HINCRBY', metrics_key, 'total_failures', -failures)
|
|
43
|
+
redis.call('HINCRBY', metrics_key, 'total_successes', -successes)
|
|
43
44
|
redis.call('ZREMRANGEBYSCORE', ts_index_key, '-inf', window_start)
|
|
44
45
|
end
|
data/lib/stoplight/version.rb
CHANGED
|
@@ -9,7 +9,7 @@ module Stoplight
|
|
|
9
9
|
attr_reader scripting: Scripting
|
|
10
10
|
attr_reader key_space: Key
|
|
11
11
|
attr_reader clock: Domain::_Clock
|
|
12
|
-
attr_reader cool_off_time: Domain::
|
|
12
|
+
attr_reader cool_off_time: Domain::duration_seconds
|
|
13
13
|
attr_reader state_key: String
|
|
14
14
|
|
|
15
15
|
def initialize: (
|
|
@@ -17,7 +17,7 @@ module Stoplight
|
|
|
17
17
|
redis: redis,
|
|
18
18
|
scripting: Scripting,
|
|
19
19
|
key_space: Key,
|
|
20
|
-
cool_off_time: Domain::
|
|
20
|
+
cool_off_time: Domain::duration_seconds
|
|
21
21
|
) -> void
|
|
22
22
|
|
|
23
23
|
def transition_to_green: -> bool
|
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: 6.0.0.
|
|
4
|
+
version: 6.0.0.rc5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tëma Bolshakov
|
|
@@ -145,6 +145,7 @@ files:
|
|
|
145
145
|
- lib/stoplight/infrastructure/redis/storage/registry.rb
|
|
146
146
|
- lib/stoplight/infrastructure/redis/storage/scripting.rb
|
|
147
147
|
- lib/stoplight/infrastructure/redis/storage/state.rb
|
|
148
|
+
- lib/stoplight/infrastructure/redis/storage/state/state_snapshot.lua
|
|
148
149
|
- lib/stoplight/infrastructure/redis/storage/state/transition_to_green.lua
|
|
149
150
|
- lib/stoplight/infrastructure/redis/storage/state/transition_to_red.lua
|
|
150
151
|
- lib/stoplight/infrastructure/redis/storage/state/transition_to_yellow.lua
|