stoplight 5.6.0 → 5.8.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 -1
- data/UPGRADING.md +303 -0
- data/lib/generators/stoplight/install/install_generator.rb +6 -1
- data/lib/stoplight/admin/dependencies.rb +1 -1
- data/lib/stoplight/admin/helpers.rb +26 -5
- data/lib/stoplight/admin/lights_repository/light.rb +22 -6
- data/lib/stoplight/admin/lights_repository.rb +20 -16
- data/lib/stoplight/admin/views/_card.erb +8 -5
- data/lib/stoplight/admin.rb +2 -1
- data/lib/stoplight/color.rb +9 -0
- data/lib/stoplight/common/deprecations.rb +11 -0
- data/lib/stoplight/data_store.rb +28 -0
- data/lib/stoplight/domain/compatibility_result.rb +7 -7
- data/lib/stoplight/domain/config.rb +38 -35
- data/lib/stoplight/domain/error_tracking_policy.rb +27 -0
- data/lib/stoplight/domain/failure.rb +1 -1
- data/lib/stoplight/domain/light/configuration_builder_interface.rb +122 -16
- data/lib/stoplight/domain/light.rb +44 -64
- data/lib/stoplight/domain/light_info.rb +7 -0
- data/lib/stoplight/domain/metrics_snapshot.rb +58 -0
- data/lib/stoplight/domain/state_snapshot.rb +29 -23
- data/lib/stoplight/domain/storage/recovery_lock_token.rb +15 -0
- data/lib/stoplight/domain/strategies/green_run_strategy.rb +18 -26
- data/lib/stoplight/domain/strategies/red_run_strategy.rb +9 -12
- data/lib/stoplight/domain/strategies/yellow_run_strategy.rb +74 -58
- data/lib/stoplight/domain/tracker/recovery_probe.rb +27 -43
- data/lib/stoplight/domain/tracker/request.rb +24 -39
- data/lib/stoplight/domain/traffic_control/consecutive_errors.rb +8 -11
- data/lib/stoplight/domain/traffic_control/error_rate.rb +19 -15
- data/lib/stoplight/domain/traffic_recovery/consecutive_successes.rb +8 -18
- data/lib/stoplight/domain/traffic_recovery.rb +3 -5
- data/lib/stoplight/error.rb +46 -0
- data/lib/stoplight/infrastructure/fail_safe/data_store.rb +152 -0
- data/lib/stoplight/infrastructure/fail_safe/storage/metrics.rb +65 -0
- data/lib/stoplight/infrastructure/fail_safe/storage/recovery_lock.rb +69 -0
- data/lib/stoplight/infrastructure/fail_safe/storage/recovery_lock_token.rb +19 -0
- data/lib/stoplight/infrastructure/fail_safe/storage/state.rb +62 -0
- data/lib/stoplight/infrastructure/{data_store/memory → memory/data_store}/metrics.rb +2 -2
- data/lib/stoplight/infrastructure/memory/data_store/recovery_lock_store.rb +52 -0
- data/lib/stoplight/infrastructure/memory/data_store/recovery_lock_token.rb +17 -0
- data/lib/stoplight/infrastructure/{data_store/memory → memory/data_store}/sliding_window.rb +21 -26
- data/lib/stoplight/infrastructure/{data_store/memory → memory/data_store}/state.rb +3 -3
- data/lib/stoplight/infrastructure/{data_store/memory.rb → memory/data_store.rb} +90 -57
- data/lib/stoplight/infrastructure/memory/storage/recovery_lock.rb +35 -0
- data/lib/stoplight/infrastructure/memory/storage/recovery_metrics.rb +16 -0
- data/lib/stoplight/infrastructure/memory/storage/state.rb +155 -0
- data/lib/stoplight/infrastructure/memory/storage/unbounded_metrics.rb +103 -0
- data/lib/stoplight/infrastructure/memory/storage/window_metrics.rb +101 -0
- data/lib/stoplight/infrastructure/notifier/fail_safe.rb +50 -0
- data/lib/stoplight/infrastructure/notifier/generic.rb +4 -14
- data/lib/stoplight/infrastructure/notifier/io.rb +1 -2
- data/lib/stoplight/infrastructure/notifier/logger.rb +1 -2
- data/lib/stoplight/infrastructure/redis/data_store/lua_scripts/record_recovery_probe_failure.lua +27 -0
- data/lib/stoplight/infrastructure/redis/data_store/lua_scripts/record_recovery_probe_success.lua +23 -0
- data/lib/stoplight/infrastructure/redis/data_store/lua_scripts/release_lock.lua +6 -0
- data/lib/stoplight/infrastructure/redis/data_store/recovery_lock_store.rb +60 -0
- data/lib/stoplight/infrastructure/redis/data_store/recovery_lock_token.rb +28 -0
- data/lib/stoplight/infrastructure/redis/data_store/scripting.rb +73 -0
- data/lib/stoplight/infrastructure/{data_store/redis.rb → redis/data_store.rb} +173 -210
- data/lib/stoplight/infrastructure/redis/storage/key_space.rb +51 -0
- data/lib/stoplight/infrastructure/redis/storage/metrics.rb +40 -0
- data/lib/stoplight/infrastructure/redis/storage/recovery_lock/release_lock.lua +6 -0
- data/lib/stoplight/infrastructure/redis/storage/recovery_lock.rb +64 -0
- data/lib/stoplight/infrastructure/redis/storage/recovery_metrics.rb +20 -0
- data/lib/stoplight/infrastructure/redis/storage/scripting.rb +18 -0
- data/lib/stoplight/infrastructure/redis/storage/state/transition_to_green.lua +10 -0
- data/lib/stoplight/infrastructure/redis/storage/state/transition_to_red.lua +10 -0
- data/lib/stoplight/infrastructure/redis/storage/state/transition_to_yellow.lua +9 -0
- data/lib/stoplight/infrastructure/redis/storage/state.rb +141 -0
- data/lib/stoplight/infrastructure/redis/storage/unbounded_metrics/record_failure.lua +28 -0
- data/lib/stoplight/infrastructure/redis/storage/unbounded_metrics/record_success.lua +26 -0
- data/lib/stoplight/infrastructure/redis/storage/unbounded_metrics.rb +123 -0
- data/lib/stoplight/infrastructure/redis/storage/window_metrics/metrics_snapshot.lua +26 -0
- data/lib/stoplight/infrastructure/redis/storage/window_metrics/record_failure.lua +36 -0
- data/lib/stoplight/infrastructure/redis/storage/window_metrics/record_success.lua +35 -0
- data/lib/stoplight/infrastructure/redis/storage/window_metrics.rb +174 -0
- data/lib/stoplight/infrastructure/storage/compatibility_metrics.rb +41 -0
- data/lib/stoplight/infrastructure/storage/compatibility_recovery_lock.rb +33 -0
- data/lib/stoplight/infrastructure/storage/compatibility_recovery_metrics.rb +47 -0
- data/lib/stoplight/infrastructure/storage/compatibility_state.rb +44 -0
- data/lib/stoplight/infrastructure/system_clock.rb +16 -0
- data/lib/stoplight/notifier.rb +11 -0
- data/lib/stoplight/state.rb +9 -0
- data/lib/stoplight/types.rb +29 -0
- data/lib/stoplight/undefined.rb +16 -0
- data/lib/stoplight/version.rb +1 -1
- data/lib/stoplight/wiring/config_compatibility_validator.rb +54 -0
- data/lib/stoplight/wiring/configuration_dsl.rb +101 -0
- data/lib/stoplight/wiring/data_store_backend.rb +26 -0
- data/lib/stoplight/wiring/default.rb +2 -2
- data/lib/stoplight/wiring/default_config.rb +21 -0
- data/lib/stoplight/wiring/default_configuration.rb +70 -53
- data/lib/stoplight/wiring/light_builder.rb +198 -0
- data/lib/stoplight/wiring/light_factory/traffic_control_dsl.rb +26 -0
- data/lib/stoplight/wiring/light_factory/traffic_recovery_dsl.rb +21 -0
- data/lib/stoplight/wiring/light_factory.rb +74 -135
- data/lib/stoplight/wiring/memory/backend.rb +57 -0
- data/lib/stoplight/wiring/notifier_factory.rb +26 -0
- data/lib/stoplight/wiring/redis/backend.rb +116 -0
- data/lib/stoplight/wiring/storage_set.rb +12 -0
- data/lib/stoplight/wiring/storage_set_builder.rb +51 -0
- data/lib/stoplight/wiring/system/light_builder.rb +47 -0
- data/lib/stoplight/wiring/system/light_factory.rb +64 -0
- data/lib/stoplight/wiring/system.rb +129 -0
- data/lib/stoplight.rb +209 -23
- data/sig/_private/generators/stoplight/install/install_generator.rbs +22 -0
- data/sig/_private/stoplight/common/deprecations.rbs +9 -0
- data/sig/_private/stoplight/data_store.rbs +6 -0
- data/sig/_private/stoplight/domain/compatibility_result.rbs +18 -0
- data/sig/_private/stoplight/domain/config.rbs +65 -0
- data/sig/_private/stoplight/domain/error_tracking_policy.rbs +14 -0
- data/sig/_private/stoplight/domain/failure.rbs +16 -0
- data/sig/_private/stoplight/domain/light.rbs +25 -0
- data/sig/_private/stoplight/domain/light_info.rbs +19 -0
- data/sig/_private/stoplight/domain/metrics_snapshot.rbs +38 -0
- data/sig/_private/stoplight/domain/ports/clock.rbs +18 -0
- data/sig/_private/stoplight/domain/ports/data_store.rbs +76 -0
- data/{lib/stoplight/domain/light_factory.rb → sig/_private/stoplight/domain/ports/light_factory.rbs} +33 -28
- data/sig/_private/stoplight/domain/ports/metrics_store.rbs +29 -0
- data/sig/_private/stoplight/domain/ports/recovery_lock_store.rbs +52 -0
- data/sig/_private/stoplight/domain/ports/recovery_lock_token.rbs +6 -0
- data/sig/_private/stoplight/domain/ports/run_strategy.rbs +14 -0
- data/sig/_private/stoplight/domain/ports/state_store.rbs +79 -0
- data/sig/_private/stoplight/domain/ports/traffic_control.rbs +41 -0
- data/sig/_private/stoplight/domain/ports/traffic_recovery.rbs +47 -0
- data/sig/_private/stoplight/domain/state_snapshot.rbs +32 -0
- data/sig/_private/stoplight/domain/storage/recovery_lock_token.rbs +11 -0
- data/sig/_private/stoplight/domain/strategies/green_run_strategy.rbs +17 -0
- data/sig/_private/stoplight/domain/strategies/red_run_strategy.rbs +17 -0
- data/sig/_private/stoplight/domain/strategies/yellow_run_strategy.rbs +42 -0
- data/sig/_private/stoplight/domain/tracker/base.rbs +8 -0
- data/sig/_private/stoplight/domain/tracker/recovery_probe.rbs +25 -0
- data/sig/_private/stoplight/domain/tracker/request.rbs +26 -0
- data/sig/_private/stoplight/domain/traffic_control/consecutive_errors.rbs +9 -0
- data/sig/_private/stoplight/domain/traffic_control/error_rate.rbs +13 -0
- data/sig/_private/stoplight/domain/traffic_recovery/consecutive_successes.rbs +9 -0
- data/sig/_private/stoplight/domain/traffic_recovery.rbs +9 -0
- data/sig/_private/stoplight/infrastructure/fail_safe/data_store.rbs +26 -0
- data/sig/_private/stoplight/infrastructure/fail_safe/storage/metrics.rbs +25 -0
- data/sig/_private/stoplight/infrastructure/fail_safe/storage/recovery_lock.rbs +29 -0
- data/sig/_private/stoplight/infrastructure/fail_safe/storage/recovery_lock_token.rbs +19 -0
- data/sig/_private/stoplight/infrastructure/fail_safe/storage/state.rbs +25 -0
- data/sig/_private/stoplight/infrastructure/memory/data_store/metrics.rbs +25 -0
- data/sig/_private/stoplight/infrastructure/memory/data_store/recovery_lock_store.rbs +19 -0
- data/sig/_private/stoplight/infrastructure/memory/data_store/recovery_lock_token.rbs +17 -0
- data/sig/_private/stoplight/infrastructure/memory/data_store/sliding_window.rbs +27 -0
- data/sig/_private/stoplight/infrastructure/memory/data_store/state.rbs +17 -0
- data/sig/_private/stoplight/infrastructure/memory/data_store.rbs +30 -0
- data/sig/_private/stoplight/infrastructure/memory/storage/recovery_lock.rbs +15 -0
- data/sig/_private/stoplight/infrastructure/memory/storage/recovery_metrics.rbs +10 -0
- data/sig/_private/stoplight/infrastructure/memory/storage/state.rbs +28 -0
- data/sig/_private/stoplight/infrastructure/memory/storage/unbounded_metrics.rbs +25 -0
- data/sig/_private/stoplight/infrastructure/memory/storage/window_metrics.rbs +26 -0
- data/sig/_private/stoplight/infrastructure/notifier/fail_safe.rbs +17 -0
- data/sig/_private/stoplight/infrastructure/notifier/generic.rbs +18 -0
- data/sig/_private/stoplight/infrastructure/notifier/io.rbs +14 -0
- data/sig/_private/stoplight/infrastructure/notifier/logger.rbs +14 -0
- data/sig/_private/stoplight/infrastructure/redis/data_store/recovery_lock_store.rbs +24 -0
- data/sig/_private/stoplight/infrastructure/redis/data_store/recovery_lock_token.rbs +21 -0
- data/sig/_private/stoplight/infrastructure/redis/data_store/scripting.rbs +34 -0
- data/sig/_private/stoplight/infrastructure/redis/data_store.rbs +67 -0
- data/sig/_private/stoplight/infrastructure/redis/storage/key_space.rbs +19 -0
- data/sig/_private/stoplight/infrastructure/redis/storage/metrics.rbs +17 -0
- data/sig/_private/stoplight/infrastructure/redis/storage/recovery_lock.rbs +26 -0
- data/sig/_private/stoplight/infrastructure/redis/storage/recovery_metrics.rbs +10 -0
- data/sig/_private/stoplight/infrastructure/redis/storage/scripting.rbs +13 -0
- data/sig/_private/stoplight/infrastructure/redis/storage/state.rbs +32 -0
- data/sig/_private/stoplight/infrastructure/redis/storage/unbounded_metrics.rbs +21 -0
- data/sig/_private/stoplight/infrastructure/redis/storage/window_metrics.rbs +34 -0
- data/sig/_private/stoplight/infrastructure/storage/compatibility_metrics.rbs +17 -0
- data/sig/_private/stoplight/infrastructure/storage/compatibility_recovery_lock.rbs +13 -0
- data/sig/_private/stoplight/infrastructure/storage/compatibility_recovery_metrics.rbs +14 -0
- data/sig/_private/stoplight/infrastructure/storage/compatibility_state.rbs +14 -0
- data/sig/_private/stoplight/infrastructure/system_clock.rbs +7 -0
- data/sig/_private/stoplight/system/light_builder.rbs +23 -0
- data/sig/_private/stoplight/system/light_factory.rbs +17 -0
- data/sig/_private/stoplight/types.rbs +6 -0
- data/sig/_private/stoplight/wiring/config_compatibility_validator.rbs +19 -0
- data/sig/_private/stoplight/wiring/configuration_dsl.rbs +43 -0
- data/sig/_private/stoplight/wiring/data_store_backend.rbs +11 -0
- data/sig/_private/stoplight/wiring/default.rbs +26 -0
- data/sig/_private/stoplight/wiring/default_config.rbs +7 -0
- data/sig/_private/stoplight/wiring/default_configuration.rbs +29 -0
- data/sig/_private/stoplight/wiring/light_builder.rbs +48 -0
- data/sig/_private/stoplight/wiring/light_factory/traffic_control_dsl.rbs +7 -0
- data/sig/_private/stoplight/wiring/light_factory/traffic_recovery_dsl.rbs +7 -0
- data/sig/_private/stoplight/wiring/light_factory.rbs +16 -0
- data/sig/_private/stoplight/wiring/memory/backend.rbs +26 -0
- data/sig/_private/stoplight/wiring/notifier_factory.rbs +10 -0
- data/sig/_private/stoplight/wiring/redis/backend.rbs +38 -0
- data/sig/_private/stoplight/wiring/storage_set.rbs +38 -0
- data/sig/_private/stoplight/wiring/storage_set_builder.rbs +15 -0
- data/sig/_private/stoplight/wiring/system.rbs +15 -0
- data/sig/_private/stoplight.rbs +48 -0
- data/sig/stoplight/color.rbs +7 -0
- data/sig/stoplight/data_store.rbs +19 -0
- data/sig/stoplight/error.rbs +20 -0
- data/sig/stoplight/notifier.rbs +11 -0
- data/sig/stoplight/ports/configuration.rbs +19 -0
- data/sig/stoplight/ports/exception_matcher.rbs +8 -0
- data/sig/stoplight/ports/light.rbs +12 -0
- data/sig/stoplight/ports/light_info.rbs +5 -0
- data/sig/stoplight/ports/state_transition_notifier.rbs +15 -0
- data/sig/stoplight/ports/system.rbs +21 -0
- data/sig/stoplight/state.rbs +7 -0
- data/sig/stoplight/undefined.rbs +9 -0
- data/sig/stoplight/version.rbs +3 -0
- data/sig/stoplight.rbs +66 -0
- metadata +199 -36
- data/lib/stoplight/domain/color.rb +0 -11
- data/lib/stoplight/domain/data_store.rb +0 -130
- data/lib/stoplight/domain/error.rb +0 -42
- data/lib/stoplight/domain/metrics.rb +0 -85
- data/lib/stoplight/domain/state.rb +0 -11
- data/lib/stoplight/domain/state_transition_notifier.rb +0 -25
- data/lib/stoplight/domain/strategies/run_strategy.rb +0 -27
- data/lib/stoplight/domain/tracker/base.rb +0 -41
- data/lib/stoplight/domain/traffic_control/base.rb +0 -74
- data/lib/stoplight/domain/traffic_recovery/base.rb +0 -80
- data/lib/stoplight/infrastructure/data_store/redis/lua.rb +0 -25
- data/lib/stoplight/infrastructure/dependency_injection/container.rb +0 -249
- data/lib/stoplight/infrastructure/dependency_injection/unresolved_dependency_error.rb +0 -13
- data/lib/stoplight/wiring/container.rb +0 -80
- data/lib/stoplight/wiring/default_factory_builder.rb +0 -25
- data/lib/stoplight/wiring/fail_safe_data_store.rb +0 -147
- data/lib/stoplight/wiring/fail_safe_notifier.rb +0 -79
- data/lib/stoplight/wiring/light/default_config.rb +0 -18
- data/lib/stoplight/wiring/light/system_config.rb +0 -11
- data/lib/stoplight/wiring/public_api.rb +0 -28
- data/lib/stoplight/wiring/system_container.rb +0 -9
- data/lib/stoplight/wiring/system_light_factory.rb +0 -17
- /data/lib/stoplight/infrastructure/{data_store/redis → redis/data_store/lua_scripts}/get_metrics.lua +0 -0
- /data/lib/stoplight/infrastructure/{data_store/redis → redis/data_store/lua_scripts}/record_failure.lua +0 -0
- /data/lib/stoplight/infrastructure/{data_store/redis → redis/data_store/lua_scripts}/record_success.lua +0 -0
- /data/lib/stoplight/infrastructure/{data_store/redis → redis/data_store/lua_scripts}/transition_to_green.lua +0 -0
- /data/lib/stoplight/infrastructure/{data_store/redis → redis/data_store/lua_scripts}/transition_to_red.lua +0 -0
- /data/lib/stoplight/infrastructure/{data_store/redis → redis/data_store/lua_scripts}/transition_to_yellow.lua +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Stoplight
|
|
4
|
+
interface _Configuration
|
|
5
|
+
def notifiers: -> Array[state_transition_notifier]
|
|
6
|
+
|
|
7
|
+
def cool_off_time=: (duration) -> void
|
|
8
|
+
def threshold=: (percentage | Integer) -> void
|
|
9
|
+
def recovery_threshold=: (Integer) -> void
|
|
10
|
+
def window_size=: (duration?) -> void
|
|
11
|
+
def tracked_errors=: (Array[_ExceptionMatcher] | _ExceptionMatcher) -> void
|
|
12
|
+
def skipped_errors=: (Array[_ExceptionMatcher] | _ExceptionMatcher) -> void
|
|
13
|
+
def traffic_control=: (traffic_control) -> void
|
|
14
|
+
def traffic_recovery=: (traffic_recovery) -> void
|
|
15
|
+
def error_notifier=: (error_notifier) -> void
|
|
16
|
+
def data_store=: (data_store) -> void
|
|
17
|
+
def notifiers=:(Array[state_transition_notifier]) -> void
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
interface _Light
|
|
3
|
+
def name: -> String
|
|
4
|
+
|
|
5
|
+
def state: -> state
|
|
6
|
+
def color: -> color
|
|
7
|
+
def run: [T] (?(^(StandardError?) -> T)?) { () -> T } -> T
|
|
8
|
+
def lock: (color) -> _Light
|
|
9
|
+
def unlock: -> _Light
|
|
10
|
+
def ==: (untyped) -> bool
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
interface _StateTransitionNotifier
|
|
3
|
+
# Sends a notification when a Stoplight changes state.
|
|
4
|
+
#
|
|
5
|
+
# @param config The Stoplight instance triggering the notification.
|
|
6
|
+
# @param from_color The previous state color of the Stoplight.
|
|
7
|
+
# @param to_color The new state color of the Stoplight.
|
|
8
|
+
# @param error The error (if any) that caused the state change.
|
|
9
|
+
def notify: (_LightInfo, color from_color, color to_color, ?StandardError? error) -> void
|
|
10
|
+
|
|
11
|
+
# Object methods needed for comparison/inspection
|
|
12
|
+
def ==: (untyped) -> bool
|
|
13
|
+
def class: -> Class
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Stoplight
|
|
4
|
+
# A System is a composition root that groups related circuit breakers
|
|
5
|
+
# with shared configuration.
|
|
6
|
+
interface _System
|
|
7
|
+
def name: -> String
|
|
8
|
+
|
|
9
|
+
def light: (
|
|
10
|
+
String name,
|
|
11
|
+
?cool_off_time: optional[duration],
|
|
12
|
+
?threshold: optional[percentage | Integer],
|
|
13
|
+
?recovery_threshold: optional[Integer],
|
|
14
|
+
?window_size: optional[duration?],
|
|
15
|
+
?skipped_errors: optional[Array[_ExceptionMatcher]],
|
|
16
|
+
?tracked_errors: optional[Array[_ExceptionMatcher]],
|
|
17
|
+
?traffic_control: optional[traffic_control],
|
|
18
|
+
?traffic_recovery: optional[traffic_recovery]
|
|
19
|
+
) -> _Light
|
|
20
|
+
end
|
|
21
|
+
end
|
data/sig/stoplight.rbs
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
type optional[T] = Undefined | T
|
|
3
|
+
|
|
4
|
+
type timestamp = Float | Integer
|
|
5
|
+
type redis = ::Redis | ConnectionPool[::Redis]
|
|
6
|
+
|
|
7
|
+
# Light Colors
|
|
8
|
+
type green = "green"
|
|
9
|
+
type yellow = "yellow"
|
|
10
|
+
type red = "red"
|
|
11
|
+
type color = green | yellow | red
|
|
12
|
+
|
|
13
|
+
# Light States
|
|
14
|
+
type unlocked = "unlocked"
|
|
15
|
+
type locked_green = "locked_green"
|
|
16
|
+
type locked_red = "locked_red"
|
|
17
|
+
type state = unlocked | locked_green | locked_red
|
|
18
|
+
|
|
19
|
+
# Duration in seconds (1, 23, 0.4, etc.)
|
|
20
|
+
type duration = Float | Integer
|
|
21
|
+
# Percentage as decimal (0.0 to 1.0)
|
|
22
|
+
type percentage = Float
|
|
23
|
+
|
|
24
|
+
type error_notifier = ^(StandardError) -> void
|
|
25
|
+
type traffic_control = :consecutive_errors | :error_rate | {error_rate: {min_requests: Integer}}
|
|
26
|
+
type traffic_recovery = :consecutive_successes
|
|
27
|
+
type data_store = DataStore::Redis | DataStore::Memory
|
|
28
|
+
type state_transition_notifier = _StateTransitionNotifier
|
|
29
|
+
type notification_formatter = ^(Domain::Config light, color, color, StandardError?) -> String
|
|
30
|
+
|
|
31
|
+
def self.configure: (?trust_me_im_an_engineer: bool) ?{ (_Configuration) -> void } -> void
|
|
32
|
+
|
|
33
|
+
def self.light: (
|
|
34
|
+
String name,
|
|
35
|
+
?cool_off_time: optional[duration],
|
|
36
|
+
?threshold: optional[percentage | Integer],
|
|
37
|
+
?recovery_threshold: optional[Integer],
|
|
38
|
+
?window_size: optional[duration?],
|
|
39
|
+
?tracked_errors: optional[Array[_ExceptionMatcher] | _ExceptionMatcher],
|
|
40
|
+
?skipped_errors: optional[Array[_ExceptionMatcher] | _ExceptionMatcher],
|
|
41
|
+
?data_store: optional[data_store],
|
|
42
|
+
?error_notifier: optional[error_notifier],
|
|
43
|
+
?notifiers: optional[Array[state_transition_notifier]],
|
|
44
|
+
?traffic_control: optional[traffic_control],
|
|
45
|
+
?traffic_recovery: optional[traffic_recovery],
|
|
46
|
+
) -> _Light
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
module Kernel
|
|
50
|
+
# For a method usable both as Kernel.Stoplight() and just Stoplight()
|
|
51
|
+
def self?.Stoplight: (
|
|
52
|
+
String name,
|
|
53
|
+
?cool_off_time: Stoplight::optional[Stoplight::duration],
|
|
54
|
+
?threshold: Stoplight::optional[Stoplight::percentage | Integer],
|
|
55
|
+
?recovery_threshold: Stoplight::optional[Integer],
|
|
56
|
+
?window_size: Stoplight::optional[Stoplight::duration?],
|
|
57
|
+
?tracked_errors: Stoplight::optional[Array[Stoplight::_ExceptionMatcher] | Stoplight::_ExceptionMatcher],
|
|
58
|
+
?skipped_errors: Stoplight::optional[Array[Stoplight::_ExceptionMatcher] | Stoplight::_ExceptionMatcher],
|
|
59
|
+
?data_store: Stoplight::optional[Stoplight::data_store],
|
|
60
|
+
?error_notifier: Stoplight::optional[Stoplight::error_notifier],
|
|
61
|
+
?notifiers: Stoplight::optional[Array[Stoplight::state_transition_notifier]],
|
|
62
|
+
?traffic_control: Stoplight::optional[Stoplight::traffic_control],
|
|
63
|
+
?traffic_recovery: Stoplight::optional[Stoplight::traffic_recovery],
|
|
64
|
+
) -> Stoplight::_Light
|
|
65
|
+
end
|
|
66
|
+
|
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: 5.
|
|
4
|
+
version: 5.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Cameron Desautels
|
|
@@ -25,6 +25,20 @@ dependencies:
|
|
|
25
25
|
- - ">="
|
|
26
26
|
- !ruby/object:Gem::Version
|
|
27
27
|
version: '0'
|
|
28
|
+
- !ruby/object:Gem::Dependency
|
|
29
|
+
name: concurrent-ruby
|
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
|
31
|
+
requirements:
|
|
32
|
+
- - ">="
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: '0'
|
|
35
|
+
type: :runtime
|
|
36
|
+
prerelease: false
|
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
38
|
+
requirements:
|
|
39
|
+
- - ">="
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: '0'
|
|
28
42
|
description: An implementation of the circuit breaker pattern.
|
|
29
43
|
email:
|
|
30
44
|
- camdez@gmail.com
|
|
@@ -37,6 +51,7 @@ files:
|
|
|
37
51
|
- CHANGELOG.md
|
|
38
52
|
- LICENSE.md
|
|
39
53
|
- README.md
|
|
54
|
+
- UPGRADING.md
|
|
40
55
|
- lib/generators/stoplight/install/USAGE
|
|
41
56
|
- lib/generators/stoplight/install/install_generator.rb
|
|
42
57
|
- lib/generators/stoplight/install/templates/stoplight.rb.erb
|
|
@@ -58,64 +73,212 @@ files:
|
|
|
58
73
|
- lib/stoplight/admin/views/_card.erb
|
|
59
74
|
- lib/stoplight/admin/views/index.erb
|
|
60
75
|
- lib/stoplight/admin/views/layout.erb
|
|
61
|
-
- lib/stoplight/
|
|
76
|
+
- lib/stoplight/color.rb
|
|
77
|
+
- lib/stoplight/common/deprecations.rb
|
|
78
|
+
- lib/stoplight/data_store.rb
|
|
62
79
|
- lib/stoplight/domain/compatibility_result.rb
|
|
63
80
|
- lib/stoplight/domain/config.rb
|
|
64
|
-
- lib/stoplight/domain/
|
|
65
|
-
- lib/stoplight/domain/error.rb
|
|
81
|
+
- lib/stoplight/domain/error_tracking_policy.rb
|
|
66
82
|
- lib/stoplight/domain/failure.rb
|
|
67
83
|
- lib/stoplight/domain/light.rb
|
|
68
84
|
- lib/stoplight/domain/light/configuration_builder_interface.rb
|
|
69
|
-
- lib/stoplight/domain/
|
|
70
|
-
- lib/stoplight/domain/
|
|
71
|
-
- lib/stoplight/domain/state.rb
|
|
85
|
+
- lib/stoplight/domain/light_info.rb
|
|
86
|
+
- lib/stoplight/domain/metrics_snapshot.rb
|
|
72
87
|
- lib/stoplight/domain/state_snapshot.rb
|
|
73
|
-
- lib/stoplight/domain/
|
|
88
|
+
- lib/stoplight/domain/storage/recovery_lock_token.rb
|
|
74
89
|
- lib/stoplight/domain/strategies/green_run_strategy.rb
|
|
75
90
|
- lib/stoplight/domain/strategies/red_run_strategy.rb
|
|
76
|
-
- lib/stoplight/domain/strategies/run_strategy.rb
|
|
77
91
|
- lib/stoplight/domain/strategies/yellow_run_strategy.rb
|
|
78
|
-
- lib/stoplight/domain/tracker/base.rb
|
|
79
92
|
- lib/stoplight/domain/tracker/recovery_probe.rb
|
|
80
93
|
- lib/stoplight/domain/tracker/request.rb
|
|
81
|
-
- lib/stoplight/domain/traffic_control/base.rb
|
|
82
94
|
- lib/stoplight/domain/traffic_control/consecutive_errors.rb
|
|
83
95
|
- lib/stoplight/domain/traffic_control/error_rate.rb
|
|
84
96
|
- lib/stoplight/domain/traffic_recovery.rb
|
|
85
|
-
- lib/stoplight/domain/traffic_recovery/base.rb
|
|
86
97
|
- lib/stoplight/domain/traffic_recovery/consecutive_successes.rb
|
|
87
|
-
- lib/stoplight/
|
|
88
|
-
- lib/stoplight/infrastructure/data_store
|
|
89
|
-
- lib/stoplight/infrastructure/
|
|
90
|
-
- lib/stoplight/infrastructure/
|
|
91
|
-
- lib/stoplight/infrastructure/
|
|
92
|
-
- lib/stoplight/infrastructure/
|
|
93
|
-
- lib/stoplight/infrastructure/data_store
|
|
94
|
-
- lib/stoplight/infrastructure/data_store/
|
|
95
|
-
- lib/stoplight/infrastructure/data_store/
|
|
96
|
-
- lib/stoplight/infrastructure/data_store/
|
|
97
|
-
- lib/stoplight/infrastructure/data_store/
|
|
98
|
-
- lib/stoplight/infrastructure/data_store/
|
|
99
|
-
- lib/stoplight/infrastructure/
|
|
100
|
-
- lib/stoplight/infrastructure/
|
|
98
|
+
- lib/stoplight/error.rb
|
|
99
|
+
- lib/stoplight/infrastructure/fail_safe/data_store.rb
|
|
100
|
+
- lib/stoplight/infrastructure/fail_safe/storage/metrics.rb
|
|
101
|
+
- lib/stoplight/infrastructure/fail_safe/storage/recovery_lock.rb
|
|
102
|
+
- lib/stoplight/infrastructure/fail_safe/storage/recovery_lock_token.rb
|
|
103
|
+
- lib/stoplight/infrastructure/fail_safe/storage/state.rb
|
|
104
|
+
- lib/stoplight/infrastructure/memory/data_store.rb
|
|
105
|
+
- lib/stoplight/infrastructure/memory/data_store/metrics.rb
|
|
106
|
+
- lib/stoplight/infrastructure/memory/data_store/recovery_lock_store.rb
|
|
107
|
+
- lib/stoplight/infrastructure/memory/data_store/recovery_lock_token.rb
|
|
108
|
+
- lib/stoplight/infrastructure/memory/data_store/sliding_window.rb
|
|
109
|
+
- lib/stoplight/infrastructure/memory/data_store/state.rb
|
|
110
|
+
- lib/stoplight/infrastructure/memory/storage/recovery_lock.rb
|
|
111
|
+
- lib/stoplight/infrastructure/memory/storage/recovery_metrics.rb
|
|
112
|
+
- lib/stoplight/infrastructure/memory/storage/state.rb
|
|
113
|
+
- lib/stoplight/infrastructure/memory/storage/unbounded_metrics.rb
|
|
114
|
+
- lib/stoplight/infrastructure/memory/storage/window_metrics.rb
|
|
115
|
+
- lib/stoplight/infrastructure/notifier/fail_safe.rb
|
|
101
116
|
- lib/stoplight/infrastructure/notifier/generic.rb
|
|
102
117
|
- lib/stoplight/infrastructure/notifier/io.rb
|
|
103
118
|
- lib/stoplight/infrastructure/notifier/logger.rb
|
|
119
|
+
- lib/stoplight/infrastructure/redis/data_store.rb
|
|
120
|
+
- lib/stoplight/infrastructure/redis/data_store/lua_scripts/get_metrics.lua
|
|
121
|
+
- lib/stoplight/infrastructure/redis/data_store/lua_scripts/record_failure.lua
|
|
122
|
+
- lib/stoplight/infrastructure/redis/data_store/lua_scripts/record_recovery_probe_failure.lua
|
|
123
|
+
- lib/stoplight/infrastructure/redis/data_store/lua_scripts/record_recovery_probe_success.lua
|
|
124
|
+
- lib/stoplight/infrastructure/redis/data_store/lua_scripts/record_success.lua
|
|
125
|
+
- lib/stoplight/infrastructure/redis/data_store/lua_scripts/release_lock.lua
|
|
126
|
+
- lib/stoplight/infrastructure/redis/data_store/lua_scripts/transition_to_green.lua
|
|
127
|
+
- lib/stoplight/infrastructure/redis/data_store/lua_scripts/transition_to_red.lua
|
|
128
|
+
- lib/stoplight/infrastructure/redis/data_store/lua_scripts/transition_to_yellow.lua
|
|
129
|
+
- lib/stoplight/infrastructure/redis/data_store/recovery_lock_store.rb
|
|
130
|
+
- lib/stoplight/infrastructure/redis/data_store/recovery_lock_token.rb
|
|
131
|
+
- lib/stoplight/infrastructure/redis/data_store/scripting.rb
|
|
132
|
+
- lib/stoplight/infrastructure/redis/storage/key_space.rb
|
|
133
|
+
- lib/stoplight/infrastructure/redis/storage/metrics.rb
|
|
134
|
+
- lib/stoplight/infrastructure/redis/storage/recovery_lock.rb
|
|
135
|
+
- lib/stoplight/infrastructure/redis/storage/recovery_lock/release_lock.lua
|
|
136
|
+
- lib/stoplight/infrastructure/redis/storage/recovery_metrics.rb
|
|
137
|
+
- lib/stoplight/infrastructure/redis/storage/scripting.rb
|
|
138
|
+
- lib/stoplight/infrastructure/redis/storage/state.rb
|
|
139
|
+
- lib/stoplight/infrastructure/redis/storage/state/transition_to_green.lua
|
|
140
|
+
- lib/stoplight/infrastructure/redis/storage/state/transition_to_red.lua
|
|
141
|
+
- lib/stoplight/infrastructure/redis/storage/state/transition_to_yellow.lua
|
|
142
|
+
- lib/stoplight/infrastructure/redis/storage/unbounded_metrics.rb
|
|
143
|
+
- lib/stoplight/infrastructure/redis/storage/unbounded_metrics/record_failure.lua
|
|
144
|
+
- lib/stoplight/infrastructure/redis/storage/unbounded_metrics/record_success.lua
|
|
145
|
+
- lib/stoplight/infrastructure/redis/storage/window_metrics.rb
|
|
146
|
+
- lib/stoplight/infrastructure/redis/storage/window_metrics/metrics_snapshot.lua
|
|
147
|
+
- lib/stoplight/infrastructure/redis/storage/window_metrics/record_failure.lua
|
|
148
|
+
- lib/stoplight/infrastructure/redis/storage/window_metrics/record_success.lua
|
|
149
|
+
- lib/stoplight/infrastructure/storage/compatibility_metrics.rb
|
|
150
|
+
- lib/stoplight/infrastructure/storage/compatibility_recovery_lock.rb
|
|
151
|
+
- lib/stoplight/infrastructure/storage/compatibility_recovery_metrics.rb
|
|
152
|
+
- lib/stoplight/infrastructure/storage/compatibility_state.rb
|
|
153
|
+
- lib/stoplight/infrastructure/system_clock.rb
|
|
154
|
+
- lib/stoplight/notifier.rb
|
|
104
155
|
- lib/stoplight/rspec.rb
|
|
105
156
|
- lib/stoplight/rspec/generic_notifier.rb
|
|
157
|
+
- lib/stoplight/state.rb
|
|
158
|
+
- lib/stoplight/types.rb
|
|
159
|
+
- lib/stoplight/undefined.rb
|
|
106
160
|
- lib/stoplight/version.rb
|
|
107
|
-
- lib/stoplight/wiring/
|
|
161
|
+
- lib/stoplight/wiring/config_compatibility_validator.rb
|
|
162
|
+
- lib/stoplight/wiring/configuration_dsl.rb
|
|
163
|
+
- lib/stoplight/wiring/data_store_backend.rb
|
|
108
164
|
- lib/stoplight/wiring/default.rb
|
|
165
|
+
- lib/stoplight/wiring/default_config.rb
|
|
109
166
|
- lib/stoplight/wiring/default_configuration.rb
|
|
110
|
-
- lib/stoplight/wiring/
|
|
111
|
-
- lib/stoplight/wiring/fail_safe_data_store.rb
|
|
112
|
-
- lib/stoplight/wiring/fail_safe_notifier.rb
|
|
113
|
-
- lib/stoplight/wiring/light/default_config.rb
|
|
114
|
-
- lib/stoplight/wiring/light/system_config.rb
|
|
167
|
+
- lib/stoplight/wiring/light_builder.rb
|
|
115
168
|
- lib/stoplight/wiring/light_factory.rb
|
|
116
|
-
- lib/stoplight/wiring/
|
|
117
|
-
- lib/stoplight/wiring/
|
|
118
|
-
- lib/stoplight/wiring/
|
|
169
|
+
- lib/stoplight/wiring/light_factory/traffic_control_dsl.rb
|
|
170
|
+
- lib/stoplight/wiring/light_factory/traffic_recovery_dsl.rb
|
|
171
|
+
- lib/stoplight/wiring/memory/backend.rb
|
|
172
|
+
- lib/stoplight/wiring/notifier_factory.rb
|
|
173
|
+
- lib/stoplight/wiring/redis/backend.rb
|
|
174
|
+
- lib/stoplight/wiring/storage_set.rb
|
|
175
|
+
- lib/stoplight/wiring/storage_set_builder.rb
|
|
176
|
+
- lib/stoplight/wiring/system.rb
|
|
177
|
+
- lib/stoplight/wiring/system/light_builder.rb
|
|
178
|
+
- lib/stoplight/wiring/system/light_factory.rb
|
|
179
|
+
- sig/_private/generators/stoplight/install/install_generator.rbs
|
|
180
|
+
- sig/_private/stoplight.rbs
|
|
181
|
+
- sig/_private/stoplight/common/deprecations.rbs
|
|
182
|
+
- sig/_private/stoplight/data_store.rbs
|
|
183
|
+
- sig/_private/stoplight/domain/compatibility_result.rbs
|
|
184
|
+
- sig/_private/stoplight/domain/config.rbs
|
|
185
|
+
- sig/_private/stoplight/domain/error_tracking_policy.rbs
|
|
186
|
+
- sig/_private/stoplight/domain/failure.rbs
|
|
187
|
+
- sig/_private/stoplight/domain/light.rbs
|
|
188
|
+
- sig/_private/stoplight/domain/light_info.rbs
|
|
189
|
+
- sig/_private/stoplight/domain/metrics_snapshot.rbs
|
|
190
|
+
- sig/_private/stoplight/domain/ports/clock.rbs
|
|
191
|
+
- sig/_private/stoplight/domain/ports/data_store.rbs
|
|
192
|
+
- sig/_private/stoplight/domain/ports/light_factory.rbs
|
|
193
|
+
- sig/_private/stoplight/domain/ports/metrics_store.rbs
|
|
194
|
+
- sig/_private/stoplight/domain/ports/recovery_lock_store.rbs
|
|
195
|
+
- sig/_private/stoplight/domain/ports/recovery_lock_token.rbs
|
|
196
|
+
- sig/_private/stoplight/domain/ports/run_strategy.rbs
|
|
197
|
+
- sig/_private/stoplight/domain/ports/state_store.rbs
|
|
198
|
+
- sig/_private/stoplight/domain/ports/traffic_control.rbs
|
|
199
|
+
- sig/_private/stoplight/domain/ports/traffic_recovery.rbs
|
|
200
|
+
- sig/_private/stoplight/domain/state_snapshot.rbs
|
|
201
|
+
- sig/_private/stoplight/domain/storage/recovery_lock_token.rbs
|
|
202
|
+
- sig/_private/stoplight/domain/strategies/green_run_strategy.rbs
|
|
203
|
+
- sig/_private/stoplight/domain/strategies/red_run_strategy.rbs
|
|
204
|
+
- sig/_private/stoplight/domain/strategies/yellow_run_strategy.rbs
|
|
205
|
+
- sig/_private/stoplight/domain/tracker/base.rbs
|
|
206
|
+
- sig/_private/stoplight/domain/tracker/recovery_probe.rbs
|
|
207
|
+
- sig/_private/stoplight/domain/tracker/request.rbs
|
|
208
|
+
- sig/_private/stoplight/domain/traffic_control/consecutive_errors.rbs
|
|
209
|
+
- sig/_private/stoplight/domain/traffic_control/error_rate.rbs
|
|
210
|
+
- sig/_private/stoplight/domain/traffic_recovery.rbs
|
|
211
|
+
- sig/_private/stoplight/domain/traffic_recovery/consecutive_successes.rbs
|
|
212
|
+
- sig/_private/stoplight/infrastructure/fail_safe/data_store.rbs
|
|
213
|
+
- sig/_private/stoplight/infrastructure/fail_safe/storage/metrics.rbs
|
|
214
|
+
- sig/_private/stoplight/infrastructure/fail_safe/storage/recovery_lock.rbs
|
|
215
|
+
- sig/_private/stoplight/infrastructure/fail_safe/storage/recovery_lock_token.rbs
|
|
216
|
+
- sig/_private/stoplight/infrastructure/fail_safe/storage/state.rbs
|
|
217
|
+
- sig/_private/stoplight/infrastructure/memory/data_store.rbs
|
|
218
|
+
- sig/_private/stoplight/infrastructure/memory/data_store/metrics.rbs
|
|
219
|
+
- sig/_private/stoplight/infrastructure/memory/data_store/recovery_lock_store.rbs
|
|
220
|
+
- sig/_private/stoplight/infrastructure/memory/data_store/recovery_lock_token.rbs
|
|
221
|
+
- sig/_private/stoplight/infrastructure/memory/data_store/sliding_window.rbs
|
|
222
|
+
- sig/_private/stoplight/infrastructure/memory/data_store/state.rbs
|
|
223
|
+
- sig/_private/stoplight/infrastructure/memory/storage/recovery_lock.rbs
|
|
224
|
+
- sig/_private/stoplight/infrastructure/memory/storage/recovery_metrics.rbs
|
|
225
|
+
- sig/_private/stoplight/infrastructure/memory/storage/state.rbs
|
|
226
|
+
- sig/_private/stoplight/infrastructure/memory/storage/unbounded_metrics.rbs
|
|
227
|
+
- sig/_private/stoplight/infrastructure/memory/storage/window_metrics.rbs
|
|
228
|
+
- sig/_private/stoplight/infrastructure/notifier/fail_safe.rbs
|
|
229
|
+
- sig/_private/stoplight/infrastructure/notifier/generic.rbs
|
|
230
|
+
- sig/_private/stoplight/infrastructure/notifier/io.rbs
|
|
231
|
+
- sig/_private/stoplight/infrastructure/notifier/logger.rbs
|
|
232
|
+
- sig/_private/stoplight/infrastructure/redis/data_store.rbs
|
|
233
|
+
- sig/_private/stoplight/infrastructure/redis/data_store/recovery_lock_store.rbs
|
|
234
|
+
- sig/_private/stoplight/infrastructure/redis/data_store/recovery_lock_token.rbs
|
|
235
|
+
- sig/_private/stoplight/infrastructure/redis/data_store/scripting.rbs
|
|
236
|
+
- sig/_private/stoplight/infrastructure/redis/storage/key_space.rbs
|
|
237
|
+
- sig/_private/stoplight/infrastructure/redis/storage/metrics.rbs
|
|
238
|
+
- sig/_private/stoplight/infrastructure/redis/storage/recovery_lock.rbs
|
|
239
|
+
- sig/_private/stoplight/infrastructure/redis/storage/recovery_metrics.rbs
|
|
240
|
+
- sig/_private/stoplight/infrastructure/redis/storage/scripting.rbs
|
|
241
|
+
- sig/_private/stoplight/infrastructure/redis/storage/state.rbs
|
|
242
|
+
- sig/_private/stoplight/infrastructure/redis/storage/unbounded_metrics.rbs
|
|
243
|
+
- sig/_private/stoplight/infrastructure/redis/storage/window_metrics.rbs
|
|
244
|
+
- sig/_private/stoplight/infrastructure/storage/compatibility_metrics.rbs
|
|
245
|
+
- sig/_private/stoplight/infrastructure/storage/compatibility_recovery_lock.rbs
|
|
246
|
+
- sig/_private/stoplight/infrastructure/storage/compatibility_recovery_metrics.rbs
|
|
247
|
+
- sig/_private/stoplight/infrastructure/storage/compatibility_state.rbs
|
|
248
|
+
- sig/_private/stoplight/infrastructure/system_clock.rbs
|
|
249
|
+
- sig/_private/stoplight/system/light_builder.rbs
|
|
250
|
+
- sig/_private/stoplight/system/light_factory.rbs
|
|
251
|
+
- sig/_private/stoplight/types.rbs
|
|
252
|
+
- sig/_private/stoplight/wiring/config_compatibility_validator.rbs
|
|
253
|
+
- sig/_private/stoplight/wiring/configuration_dsl.rbs
|
|
254
|
+
- sig/_private/stoplight/wiring/data_store_backend.rbs
|
|
255
|
+
- sig/_private/stoplight/wiring/default.rbs
|
|
256
|
+
- sig/_private/stoplight/wiring/default_config.rbs
|
|
257
|
+
- sig/_private/stoplight/wiring/default_configuration.rbs
|
|
258
|
+
- sig/_private/stoplight/wiring/light_builder.rbs
|
|
259
|
+
- sig/_private/stoplight/wiring/light_factory.rbs
|
|
260
|
+
- sig/_private/stoplight/wiring/light_factory/traffic_control_dsl.rbs
|
|
261
|
+
- sig/_private/stoplight/wiring/light_factory/traffic_recovery_dsl.rbs
|
|
262
|
+
- sig/_private/stoplight/wiring/memory/backend.rbs
|
|
263
|
+
- sig/_private/stoplight/wiring/notifier_factory.rbs
|
|
264
|
+
- sig/_private/stoplight/wiring/redis/backend.rbs
|
|
265
|
+
- sig/_private/stoplight/wiring/storage_set.rbs
|
|
266
|
+
- sig/_private/stoplight/wiring/storage_set_builder.rbs
|
|
267
|
+
- sig/_private/stoplight/wiring/system.rbs
|
|
268
|
+
- sig/stoplight.rbs
|
|
269
|
+
- sig/stoplight/color.rbs
|
|
270
|
+
- sig/stoplight/data_store.rbs
|
|
271
|
+
- sig/stoplight/error.rbs
|
|
272
|
+
- sig/stoplight/notifier.rbs
|
|
273
|
+
- sig/stoplight/ports/configuration.rbs
|
|
274
|
+
- sig/stoplight/ports/exception_matcher.rbs
|
|
275
|
+
- sig/stoplight/ports/light.rbs
|
|
276
|
+
- sig/stoplight/ports/light_info.rbs
|
|
277
|
+
- sig/stoplight/ports/state_transition_notifier.rbs
|
|
278
|
+
- sig/stoplight/ports/system.rbs
|
|
279
|
+
- sig/stoplight/state.rbs
|
|
280
|
+
- sig/stoplight/undefined.rbs
|
|
281
|
+
- sig/stoplight/version.rbs
|
|
119
282
|
homepage: https://github.com/bolshakov/stoplight
|
|
120
283
|
licenses:
|
|
121
284
|
- MIT
|
|
@@ -134,7 +297,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
134
297
|
- !ruby/object:Gem::Version
|
|
135
298
|
version: '0'
|
|
136
299
|
requirements: []
|
|
137
|
-
rubygems_version:
|
|
300
|
+
rubygems_version: 4.0.3
|
|
138
301
|
specification_version: 4
|
|
139
302
|
summary: Traffic control for code.
|
|
140
303
|
test_files: []
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Stoplight
|
|
4
|
-
module Domain
|
|
5
|
-
# @abstract
|
|
6
|
-
# :nocov:
|
|
7
|
-
class DataStore
|
|
8
|
-
METRICS_RETENTION_TIME = 60 * 60 * 24 # 1 day
|
|
9
|
-
|
|
10
|
-
# Retrieves the names of all lights stored in the data store.
|
|
11
|
-
#
|
|
12
|
-
# @return [Array<String>] An array of light names.
|
|
13
|
-
def names
|
|
14
|
-
raise NotImplementedError
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
# Retrieves metrics for a specific light configuration.
|
|
18
|
-
#
|
|
19
|
-
# @param config [Stoplight::Domain::Config]
|
|
20
|
-
# @return [Stoplight::Domain::Metrics]
|
|
21
|
-
def get_metrics(config)
|
|
22
|
-
raise NotImplementedError
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
# Retrieves recovery metrics for a specific light configuration.
|
|
26
|
-
#
|
|
27
|
-
# @param config [Stoplight::Domain::Config]
|
|
28
|
-
# @return [Stoplight::Domain::Metrics]
|
|
29
|
-
def get_recovery_metrics(config)
|
|
30
|
-
raise NotImplementedError
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
# Retrieves State Snapshot for a specific light configuration.
|
|
34
|
-
#
|
|
35
|
-
# @param config [Stoplight::Domain::Config] The light configuration.
|
|
36
|
-
# @return [Stoplight::Domain::StateSnapshot]
|
|
37
|
-
def get_state_snapshot(config)
|
|
38
|
-
raise NotImplementedError
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
# Clears windowed metrics (successes/errors) to prevent
|
|
42
|
-
# stale failures from before recovery from affecting post-recovery decisions.
|
|
43
|
-
# Consecutive counts are intentionally preserved as they track current streaks.
|
|
44
|
-
#
|
|
45
|
-
# @param config [Stoplight::Domain::Config] The light configuration.
|
|
46
|
-
# @return [void]
|
|
47
|
-
def clear_windowed_metrics(config)
|
|
48
|
-
raise NotImplementedError
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
# Records a failure for a specific light configuration.
|
|
52
|
-
#
|
|
53
|
-
# @param config [Stoplight::Domain::Config]
|
|
54
|
-
# @param exception [Exception]
|
|
55
|
-
# @return [void]
|
|
56
|
-
def record_failure(config, exception)
|
|
57
|
-
raise NotImplementedError
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
# Records a success for a specific light configuration.
|
|
61
|
-
#
|
|
62
|
-
# @param config [Stoplight::Domain::Config]
|
|
63
|
-
# @return [void]
|
|
64
|
-
def record_success(config)
|
|
65
|
-
raise NotImplementedError
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
# Records a failed recovery probe for a specific light configuration.
|
|
69
|
-
#
|
|
70
|
-
# @param config [Stoplight::Domain::Config]
|
|
71
|
-
# @param failure [Failure]
|
|
72
|
-
# @return [void]
|
|
73
|
-
def record_recovery_probe_failure(config, failure)
|
|
74
|
-
raise NotImplementedError
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
# Records a successful recovery probe for a specific light configuration.
|
|
78
|
-
#
|
|
79
|
-
# @param config [Stoplight::Domain::Config]
|
|
80
|
-
# @return [void]
|
|
81
|
-
def record_recovery_probe_success(config)
|
|
82
|
-
raise NotImplementedError
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
# Sets the state of a specific light configuration.
|
|
86
|
-
#
|
|
87
|
-
# @param config [Stoplight::Domain::Config]
|
|
88
|
-
# @param state [String] The new state to set.
|
|
89
|
-
# @return [String] The state that was set.
|
|
90
|
-
def set_state(config, state)
|
|
91
|
-
raise NotImplementedError
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
# Transitions the Stoplight to the specified color.
|
|
95
|
-
#
|
|
96
|
-
# This method performs a color transition operation that works across distributed instances
|
|
97
|
-
# of the light. It ensures that in a multi-instance environment, only one instance
|
|
98
|
-
# is considered the "first" to perform the transition (and therefore responsible for
|
|
99
|
-
# triggering notifications).
|
|
100
|
-
#
|
|
101
|
-
# @param config [Stoplight::Domain::Config]
|
|
102
|
-
# @param color [String] The target color/state to transition to.
|
|
103
|
-
# Should be one of Stoplight::Color::GREEN, Stoplight::Color::YELLOW, or Stoplight::Color::RED.
|
|
104
|
-
#
|
|
105
|
-
# @return [Boolean] Returns +true+ if this instance was the first to perform this specific transition
|
|
106
|
-
# (and should therefore trigger notifications). Returns +false+ if another instance already
|
|
107
|
-
# initiated this transition.
|
|
108
|
-
#
|
|
109
|
-
# @note In distributed environments with multiple instances, race conditions can occur when instances
|
|
110
|
-
# attempt conflicting transitions simultaneously (e.g., one instance tries to transition from
|
|
111
|
-
# YELLOW to GREEN while another tries YELLOW to RED). The implementation handles this, but
|
|
112
|
-
# be aware that the last operation may determine the final color of the light.
|
|
113
|
-
#
|
|
114
|
-
def transition_to_color(config, color)
|
|
115
|
-
raise NotImplementedError
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
# Deletes metadata (and related persistent state) for the given light.
|
|
119
|
-
#
|
|
120
|
-
# Implementations may choose to only remove metadata; metrics may expire via TTL.
|
|
121
|
-
#
|
|
122
|
-
# @param config [Stoplight::Domain::Config]
|
|
123
|
-
# @return [void]
|
|
124
|
-
def delete_light(config)
|
|
125
|
-
raise NotImplementedError
|
|
126
|
-
end
|
|
127
|
-
end
|
|
128
|
-
# :nocov:
|
|
129
|
-
end
|
|
130
|
-
end
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Stoplight
|
|
4
|
-
module Domain
|
|
5
|
-
module Error
|
|
6
|
-
Base = Class.new(StandardError)
|
|
7
|
-
ConfigurationError = Class.new(Base)
|
|
8
|
-
IncorrectColor = Class.new(Base)
|
|
9
|
-
|
|
10
|
-
class RedLight < Base
|
|
11
|
-
# @!attribute light_name
|
|
12
|
-
# @return [String] The light's name
|
|
13
|
-
attr_reader :light_name
|
|
14
|
-
|
|
15
|
-
# @!attribute cool_off_time
|
|
16
|
-
# @return [Numeric] Cool-off period in seconds
|
|
17
|
-
attr_reader :cool_off_time
|
|
18
|
-
|
|
19
|
-
# @!attribute retry_after
|
|
20
|
-
# @return [Time] Absolute Time after which a recovery attempt can occur
|
|
21
|
-
attr_reader :retry_after
|
|
22
|
-
|
|
23
|
-
# Initializes a new RedLight error.
|
|
24
|
-
#
|
|
25
|
-
# @param light_name [String] The light's name
|
|
26
|
-
#
|
|
27
|
-
# @option cool_off_time [Numeric] Cool-off period in seconds
|
|
28
|
-
#
|
|
29
|
-
# @option retry_after [Time] Absolute Time after which a recovery attempt can occur
|
|
30
|
-
#
|
|
31
|
-
# @return [Stoplight::Error::RedLight]
|
|
32
|
-
def initialize(light_name, cool_off_time:, retry_after:)
|
|
33
|
-
@light_name = light_name
|
|
34
|
-
@cool_off_time = cool_off_time
|
|
35
|
-
@retry_after = retry_after
|
|
36
|
-
|
|
37
|
-
super(light_name)
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|