stoplight 5.0.1 → 5.0.2
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/lib/stoplight/admin/views/layout.erb +35 -33
- data/lib/stoplight/data_store/fail_safe.rb +6 -5
- data/lib/stoplight/data_store/redis.rb +44 -23
- data/lib/stoplight/version.rb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33957e89681161b7eee07f1ea96544341f0be3b988a53609829450f13a5840e9
|
4
|
+
data.tar.gz: cdad58020fe3e1e85b2705cc6d0b1fc733b994717860c911dfab0c9a375b074d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e97d13c334f95e586dd561ad3ba3c2a5e7c3f37ef830efca794e1bde280f8f22ebbf3baa02efc61f0978dde42d9d6551aafdef6d1d35f8d2589d7d18c46b84ca
|
7
|
+
data.tar.gz: e0841a8040fc194c1b271f0dad0550200ea1bc73982545d7143e77c5e4eb867d6b4f9d94d1f5e292833ce1cd3091a6839bfc66b6a62d78ea73468735c6f09ead
|
@@ -15,43 +15,45 @@
|
|
15
15
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flowbite@3.1.2/dist/flowbite.min.css" />
|
16
16
|
</head>
|
17
17
|
<body>
|
18
|
-
<div class="antialiased bg-gray-50 dark:bg-gray-900">
|
19
|
-
<
|
20
|
-
<
|
21
|
-
<
|
22
|
-
|
23
|
-
|
24
|
-
|
18
|
+
<div class="antialiased bg-gray-50 dark:bg-gray-900 h-screen flex flex-col justify-between">
|
19
|
+
<div>
|
20
|
+
<nav class="bg-white border-gray-200 dark:bg-gray-900">
|
21
|
+
<div class="max-w-screen-xl flex flex-wrap items-center justify-between mx-auto p-4">
|
22
|
+
<a href="<%= url('/') %>" class="flex items-center space-x-3 rtl:space-x-reverse">
|
23
|
+
🚦
|
24
|
+
<span class="self-center text-2xl font-semibold whitespace-nowrap dark:text-white">Stoplight Admin</span>
|
25
|
+
</a>
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
<button data-collapse-toggle="navbar-default" type="button" class="inline-flex items-center p-2 w-10 h-10 justify-center text-sm text-gray-500 rounded-lg md:hidden hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-gray-200 dark:text-gray-400 dark:hover:bg-gray-700 dark:focus:ring-gray-600" aria-controls="navbar-default" aria-expanded="false">
|
28
|
+
<span class="sr-only">Open main menu</span>
|
29
|
+
<svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 17 14">
|
30
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M1 1h15M1 7h15M1 13h15"/>
|
31
|
+
</svg>
|
32
|
+
</button>
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
34
|
+
<div class="hidden w-full md:block md:w-auto" id="navbar-default">
|
35
|
+
<ul class="font-medium flex flex-col p-4 md:p-0 mt-4 border border-gray-100 rounded-lg bg-gray-50 md:flex-row md:space-x-8 rtl:space-x-reverse md:mt-0 md:border-0 md:bg-white dark:bg-gray-800 md:dark:bg-gray-900 dark:border-gray-700">
|
36
|
+
<% if count_red + count_yellow > 0 %>
|
37
|
+
<li>
|
38
|
+
<a href="<%= url('/green_all') %>" data-turbo-method="post" class="inline-flex items-center text-gray-900 bg-white border border-gray-300 focus:outline-none hover:bg-gray-100 focus:ring-4 focus:ring-gray-100 font-medium rounded-lg text-sm px-5 py-2.5 me-2 mb-2 dark:bg-gray-800 dark:text-white dark:border-gray-600 dark:hover:bg-gray-700 dark:hover:border-gray-600 dark:focus:ring-gray-700">
|
39
|
+
<svg class="flex w-4 h-4 me-1.5 text-green-600 shrink-0" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
40
|
+
<circle cx="12" cy="16" r="1"/>
|
41
|
+
<rect x="3" y="10" width="18" height="12" rx="2"/>
|
42
|
+
<path d="M7 10V7a5 5 0 0 1 10 0v3"/>
|
43
|
+
</svg>
|
44
|
+
Lock All Green
|
45
|
+
</a>
|
46
|
+
</li>
|
47
|
+
<% end %>
|
48
|
+
</ul>
|
49
|
+
</div>
|
48
50
|
</div>
|
49
|
-
</
|
50
|
-
</nav>
|
51
|
+
</nav>
|
51
52
|
|
52
|
-
|
53
|
-
|
54
|
-
|
53
|
+
<main class="p-4 md:ml-64 h-auto">
|
54
|
+
<%= yield %>
|
55
|
+
</main>
|
56
|
+
</div>
|
55
57
|
|
56
58
|
<footer class="bg-white rounded-lg shadow-sm dark:bg-gray-900 m-4">
|
57
59
|
<div class="w-full max-w-screen-xl mx-auto p-4 md:py-8">
|
@@ -12,10 +12,6 @@ module Stoplight
|
|
12
12
|
# @return [Stoplight::DataStore::Base] The underlying data store being wrapped.
|
13
13
|
protected attr_reader :data_store
|
14
14
|
|
15
|
-
# @!attribute [r] circuit_breaker
|
16
|
-
# @return [Stoplight] The circuit breaker used to handle failures.
|
17
|
-
private attr_reader :circuit_breaker
|
18
|
-
|
19
15
|
class << self
|
20
16
|
# Wraps a data store with fail-safe mechanisms.
|
21
17
|
#
|
@@ -35,7 +31,6 @@ module Stoplight
|
|
35
31
|
# @param data_store [Stoplight::DataStore::Base]
|
36
32
|
def initialize(data_store)
|
37
33
|
@data_store = data_store
|
38
|
-
@circuit_breaker = Stoplight("stoplight:data_store:fail_safe:#{data_store.class.name}", data_store: Default::DATA_STORE)
|
39
34
|
end
|
40
35
|
|
41
36
|
def names
|
@@ -100,6 +95,12 @@ module Stoplight
|
|
100
95
|
|
101
96
|
circuit_breaker.run(fallback, &code)
|
102
97
|
end
|
98
|
+
|
99
|
+
# @!attribute [r] circuit_breaker
|
100
|
+
# @return [Stoplight] The circuit breaker used to handle failures.
|
101
|
+
private def circuit_breaker
|
102
|
+
@circuit_breaker ||= Stoplight("stoplight:data_store:fail_safe:#{data_store.class.name}", data_store: Default::DATA_STORE)
|
103
|
+
end
|
103
104
|
end
|
104
105
|
end
|
105
106
|
end
|
@@ -79,21 +79,6 @@ module Stoplight
|
|
79
79
|
def initialize(redis, warn_on_clock_skew: true)
|
80
80
|
@warn_on_clock_skew = warn_on_clock_skew
|
81
81
|
@redis = redis
|
82
|
-
@redis.then do |client|
|
83
|
-
@record_failure_sha,
|
84
|
-
@record_success_sha,
|
85
|
-
@get_metadata_sha,
|
86
|
-
@transition_to_yellow_sha,
|
87
|
-
@transition_to_red_sha,
|
88
|
-
@transition_to_green_sha = client.pipelined do |pipeline|
|
89
|
-
pipeline.script("load", Lua::RECORD_FAILURE)
|
90
|
-
pipeline.script("load", Lua::RECORD_SUCCESS)
|
91
|
-
pipeline.script("load", Lua::GET_METADATA)
|
92
|
-
pipeline.script("load", Lua::TRANSITION_TO_YELLOW)
|
93
|
-
pipeline.script("load", Lua::TRANSITION_TO_RED)
|
94
|
-
pipeline.script("load", Lua::TRANSITION_TO_GREEN)
|
95
|
-
end
|
96
|
-
end
|
97
82
|
end
|
98
83
|
|
99
84
|
def names
|
@@ -126,7 +111,7 @@ module Stoplight
|
|
126
111
|
|
127
112
|
successes, errors, recovery_probe_successes, recovery_probe_errors, meta = @redis.with do |client|
|
128
113
|
client.evalsha(
|
129
|
-
|
114
|
+
get_metadata_sha,
|
130
115
|
argv: [
|
131
116
|
failure_keys.count,
|
132
117
|
recovery_probe_failure_keys.count,
|
@@ -166,7 +151,7 @@ module Stoplight
|
|
166
151
|
|
167
152
|
@redis.then do |client|
|
168
153
|
client.evalsha(
|
169
|
-
|
154
|
+
record_failure_sha,
|
170
155
|
argv: [current_ts, SecureRandom.hex(12), failure_json, metrics_ttl, metadata_ttl],
|
171
156
|
keys: [
|
172
157
|
metadata_key(config),
|
@@ -182,7 +167,7 @@ module Stoplight
|
|
182
167
|
|
183
168
|
@redis.then do |client|
|
184
169
|
client.evalsha(
|
185
|
-
|
170
|
+
record_success_sha,
|
186
171
|
argv: [request_ts, request_id, metrics_ttl, metadata_ttl],
|
187
172
|
keys: [
|
188
173
|
metadata_key(config),
|
@@ -203,7 +188,7 @@ module Stoplight
|
|
203
188
|
|
204
189
|
@redis.then do |client|
|
205
190
|
client.evalsha(
|
206
|
-
|
191
|
+
record_failure_sha,
|
207
192
|
argv: [current_ts, SecureRandom.uuid, failure_json, metrics_ttl, metrics_ttl],
|
208
193
|
keys: [
|
209
194
|
metadata_key(config),
|
@@ -225,7 +210,7 @@ module Stoplight
|
|
225
210
|
|
226
211
|
@redis.then do |client|
|
227
212
|
client.evalsha(
|
228
|
-
|
213
|
+
record_success_sha,
|
229
214
|
argv: [request_ts, request_id, metrics_ttl, metadata_ttl],
|
230
215
|
keys: [
|
231
216
|
metadata_key(config),
|
@@ -274,7 +259,7 @@ module Stoplight
|
|
274
259
|
|
275
260
|
became_green = @redis.then do |client|
|
276
261
|
client.evalsha(
|
277
|
-
|
262
|
+
transition_to_green_sha,
|
278
263
|
argv: [current_ts],
|
279
264
|
keys: [meta_key]
|
280
265
|
)
|
@@ -293,7 +278,7 @@ module Stoplight
|
|
293
278
|
|
294
279
|
became_yellow = @redis.then do |client|
|
295
280
|
client.evalsha(
|
296
|
-
|
281
|
+
transition_to_yellow_sha,
|
297
282
|
argv: [current_ts],
|
298
283
|
keys: [meta_key]
|
299
284
|
)
|
@@ -313,7 +298,7 @@ module Stoplight
|
|
313
298
|
|
314
299
|
became_red = @redis.then do |client|
|
315
300
|
client.evalsha(
|
316
|
-
|
301
|
+
transition_to_red_sha,
|
317
302
|
argv: [current_ts, recovery_scheduled_after_ts],
|
318
303
|
keys: [meta_key]
|
319
304
|
)
|
@@ -418,6 +403,42 @@ module Stoplight
|
|
418
403
|
private def should_sample?(probability)
|
419
404
|
rand <= probability
|
420
405
|
end
|
406
|
+
|
407
|
+
private def record_success_sha
|
408
|
+
@record_success_sha ||= @redis.then do |client|
|
409
|
+
client.script("load", Lua::RECORD_SUCCESS)
|
410
|
+
end
|
411
|
+
end
|
412
|
+
|
413
|
+
private def get_metadata_sha
|
414
|
+
@get_metadata_sha ||= @redis.then do |client|
|
415
|
+
client.script("load", Lua::GET_METADATA)
|
416
|
+
end
|
417
|
+
end
|
418
|
+
|
419
|
+
private def transition_to_yellow_sha
|
420
|
+
@transition_to_yellow_sha ||= @redis.then do |client|
|
421
|
+
client.script("load", Lua::TRANSITION_TO_YELLOW)
|
422
|
+
end
|
423
|
+
end
|
424
|
+
|
425
|
+
private def transition_to_red_sha
|
426
|
+
@transition_to_red_sha ||= @redis.then do |client|
|
427
|
+
client.script("load", Lua::TRANSITION_TO_RED)
|
428
|
+
end
|
429
|
+
end
|
430
|
+
|
431
|
+
private def transition_to_green_sha
|
432
|
+
@transition_to_green_sha ||= @redis.then do |client|
|
433
|
+
client.script("load", Lua::TRANSITION_TO_GREEN)
|
434
|
+
end
|
435
|
+
end
|
436
|
+
|
437
|
+
private def record_failure_sha
|
438
|
+
@record_failure_sha ||= @redis.then do |client|
|
439
|
+
client.script("load", Lua::RECORD_FAILURE)
|
440
|
+
end
|
441
|
+
end
|
421
442
|
end
|
422
443
|
end
|
423
444
|
end
|
data/lib/stoplight/version.rb
CHANGED
metadata
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stoplight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cameron Desautels
|
8
8
|
- Taylor Fausak
|
9
9
|
- Justin Steffy
|
10
|
-
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date: 2025-06-
|
12
|
+
date: 2025-06-22 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: zeitwerk
|
@@ -99,7 +98,6 @@ homepage: https://github.com/bolshakov/stoplight
|
|
99
98
|
licenses:
|
100
99
|
- MIT
|
101
100
|
metadata: {}
|
102
|
-
post_install_message:
|
103
101
|
rdoc_options: []
|
104
102
|
require_paths:
|
105
103
|
- lib
|
@@ -114,8 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
112
|
- !ruby/object:Gem::Version
|
115
113
|
version: '0'
|
116
114
|
requirements: []
|
117
|
-
rubygems_version: 3.
|
118
|
-
signing_key:
|
115
|
+
rubygems_version: 3.6.5
|
119
116
|
specification_version: 4
|
120
117
|
summary: Traffic control for code.
|
121
118
|
test_files: []
|