stoplight 5.8.3 → 6.0.0.rc2
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/CHANGELOG.md +1 -1
- data/LICENSE.md +1 -0
- data/README.md +132 -79
- data/UPGRADING.md +265 -6
- data/lib/stoplight/admin/actions/action.rb +4 -12
- data/lib/stoplight/admin/actions/lock.rb +12 -9
- data/lib/stoplight/admin/actions/lock_all.rb +27 -0
- data/lib/stoplight/admin/actions/remove.rb +12 -9
- data/lib/stoplight/admin/actions/stats.rb +15 -12
- data/lib/stoplight/admin/actions/unlock.rb +10 -9
- data/lib/stoplight/admin/assets/apple-touch-icon.png +0 -0
- data/lib/stoplight/admin/assets/favicon.ico +0 -0
- data/lib/stoplight/admin/assets/flowbite.min.css +2 -0
- data/lib/stoplight/admin/assets/flowbite.min.js +1 -0
- data/lib/stoplight/admin/assets/icon.svg +7 -0
- data/lib/stoplight/admin/assets/turbo.es2017-esm.min.js +34 -0
- data/lib/stoplight/admin/config_registry.rb +40 -0
- data/lib/stoplight/admin/dependencies.rb +29 -28
- data/lib/stoplight/admin/helpers.rb +50 -17
- data/lib/stoplight/admin/light_view.rb +184 -0
- data/lib/stoplight/admin/lights_stats.rb +7 -9
- data/lib/stoplight/admin/views/_card.erb +19 -21
- data/lib/stoplight/admin/views/index.erb +9 -3
- data/lib/stoplight/admin/views/layout.erb +45 -13
- data/lib/stoplight/admin.rb +110 -21
- data/lib/stoplight/data_store.rb +18 -8
- data/lib/stoplight/domain/config.rb +4 -1
- data/lib/stoplight/domain/error_tracking_policy.rb +9 -0
- data/lib/stoplight/domain/failure.rb +4 -0
- data/lib/stoplight/domain/id.rb +13 -0
- data/lib/stoplight/domain/light.rb +35 -77
- data/lib/stoplight/domain/lock_control.rb +55 -0
- data/lib/stoplight/domain/matcher_validator.rb +24 -0
- data/lib/stoplight/domain/state_snapshot.rb +2 -6
- data/lib/stoplight/domain/strategies/green_run_strategy.rb +33 -19
- data/lib/stoplight/domain/strategies/red_run_strategy.rb +8 -2
- data/lib/stoplight/domain/strategies/yellow_run_strategy.rb +56 -32
- data/lib/stoplight/domain/telemetry/bus.rb +90 -0
- data/lib/stoplight/domain/telemetry/consumer.rb +18 -0
- data/lib/stoplight/domain/telemetry/emitter.rb +45 -0
- data/lib/stoplight/domain/telemetry/envelope.rb +15 -0
- data/lib/stoplight/domain/telemetry/failure.rb +13 -0
- data/lib/stoplight/domain/telemetry/light_registered.rb +12 -0
- data/lib/stoplight/domain/telemetry/lock_changed.rb +19 -0
- data/lib/stoplight/domain/telemetry/metrics.rb +15 -0
- data/lib/stoplight/domain/telemetry/recovery_failed.rb +20 -0
- data/lib/stoplight/domain/telemetry/recovery_probe_completed.rb +15 -0
- data/lib/stoplight/domain/telemetry/recovery_started.rb +18 -0
- data/lib/stoplight/domain/telemetry/recovery_succeeded.rb +19 -0
- data/lib/stoplight/domain/telemetry/run_completed.rb +17 -0
- data/lib/stoplight/domain/telemetry/run_recorder.rb +58 -0
- data/lib/stoplight/domain/telemetry/settings.rb +21 -0
- data/lib/stoplight/domain/telemetry/state_transitioned.rb +11 -0
- data/lib/stoplight/domain/telemetry/subscription.rb +11 -0
- data/lib/stoplight/domain/telemetry/traffic_breached.rb +20 -0
- data/lib/stoplight/domain/tracker/recovery_probe.rb +61 -17
- data/lib/stoplight/domain/tracker/request.rb +17 -8
- data/lib/stoplight/domain/traffic_control/consecutive_errors.rb +13 -3
- data/lib/stoplight/domain/traffic_control/error_rate.rb +16 -12
- data/lib/stoplight/domain/traffic_recovery/consecutive_successes.rb +9 -3
- data/lib/stoplight/error.rb +10 -1
- data/lib/stoplight/infrastructure/config_serializer.rb +50 -0
- data/lib/stoplight/infrastructure/fail_safe/error_notifier.rb +25 -0
- data/lib/stoplight/infrastructure/fail_safe/storage/registry.rb +68 -0
- data/lib/stoplight/infrastructure/memory/storage/registry.rb +18 -0
- data/lib/stoplight/infrastructure/memory/storage/unbounded_metrics.rb +29 -32
- data/lib/stoplight/infrastructure/memory/storage/window_metrics/sliding_window.rb +74 -0
- data/lib/stoplight/infrastructure/memory/storage/window_metrics.rb +25 -24
- data/lib/stoplight/infrastructure/notifier/fail_safe.rb +3 -8
- data/lib/stoplight/infrastructure/notifier/generic.rb +3 -3
- data/lib/stoplight/infrastructure/redis/key.rb +25 -0
- data/lib/stoplight/infrastructure/redis/storage/now.lua +9 -0
- data/lib/stoplight/infrastructure/redis/storage/recovery_lock.rb +2 -4
- data/lib/stoplight/infrastructure/redis/storage/recovery_metrics.rb +1 -1
- data/lib/stoplight/infrastructure/redis/storage/registry.rb +73 -0
- data/lib/stoplight/infrastructure/redis/storage/scripting.rb +54 -3
- data/lib/stoplight/infrastructure/redis/storage/state/transition_to_green.lua +3 -1
- data/lib/stoplight/infrastructure/redis/storage/state/transition_to_red.lua +4 -2
- data/lib/stoplight/infrastructure/redis/storage/state/transition_to_yellow.lua +3 -1
- data/lib/stoplight/infrastructure/redis/storage/state.rb +8 -8
- data/lib/stoplight/infrastructure/redis/storage/unbounded_metrics/record_failure.lua +20 -21
- data/lib/stoplight/infrastructure/redis/storage/unbounded_metrics/record_success.lua +11 -19
- data/lib/stoplight/infrastructure/redis/storage/unbounded_metrics.rb +20 -16
- data/lib/stoplight/infrastructure/redis/storage/window_metrics/_evict.lua +44 -0
- data/lib/stoplight/infrastructure/redis/storage/window_metrics/metrics_snapshot.lua +14 -21
- data/lib/stoplight/infrastructure/redis/storage/window_metrics/record_failure.lua +38 -36
- data/lib/stoplight/infrastructure/redis/storage/window_metrics/record_success.lua +23 -30
- data/lib/stoplight/infrastructure/redis/storage/window_metrics.rb +45 -135
- data/lib/stoplight/infrastructure/system_clock.rb +4 -0
- data/lib/stoplight/telemetry.rb +19 -0
- data/lib/stoplight/types.rb +15 -2
- data/lib/stoplight/version.rb +1 -1
- data/lib/stoplight/wiring/config_compatibility_validator.rb +25 -2
- data/lib/stoplight/wiring/default.rb +1 -1
- data/lib/stoplight/wiring/default_config.rb +2 -1
- data/lib/stoplight/wiring/default_configuration.rb +3 -2
- data/lib/stoplight/wiring/external_caller.rb +27 -0
- data/lib/stoplight/wiring/fail_safe_config.rb +11 -0
- data/lib/stoplight/wiring/global_state.rb +93 -0
- data/lib/stoplight/wiring/{light_factory → light_configuration_dsl}/traffic_control_dsl.rb +3 -5
- data/lib/stoplight/wiring/{light_factory → light_configuration_dsl}/traffic_recovery_dsl.rb +2 -2
- data/lib/stoplight/wiring/light_configuration_dsl.rb +97 -0
- data/lib/stoplight/wiring/light_factory.rb +154 -97
- data/lib/stoplight/wiring/notifier_bridge.rb +33 -0
- data/lib/stoplight/wiring/redis/backend.rb +1 -1
- data/lib/stoplight/wiring/system/storage.rb +69 -0
- data/lib/stoplight/wiring/system.rb +125 -56
- data/lib/stoplight/wiring/{configuration_dsl.rb → system_configuration_dsl.rb} +13 -43
- data/lib/stoplight.rb +50 -194
- data/sig/sinatra/base.rbs +6 -0
- data/sig/stdlib/securerandom.rbs +4 -0
- data/sig/stoplight/admin/actions/action.rbs +10 -0
- data/sig/stoplight/admin/actions/lock.rbs +17 -0
- data/sig/stoplight/admin/actions/lock_all.rbs +17 -0
- data/sig/stoplight/admin/actions/remove.rbs +22 -0
- data/sig/stoplight/admin/actions/stats.rbs +28 -0
- data/sig/stoplight/admin/actions/unlock.rbs +17 -0
- data/sig/stoplight/admin/config_registry.rbs +20 -0
- data/sig/stoplight/admin/dependencies.rbs +16 -0
- data/sig/stoplight/admin/helpers.rbs +17 -0
- data/sig/stoplight/admin/light_view.rbs +39 -0
- data/sig/stoplight/admin/lights_stats.rbs +30 -0
- data/sig/stoplight/admin.rbs +14 -0
- data/sig/stoplight/color.rbs +3 -3
- data/sig/{_private/stoplight/data_store.rbs → stoplight/data_store/base.rbs} +1 -0
- data/sig/stoplight/data_store/memory.rbs +9 -0
- data/sig/stoplight/data_store/redis.rbs +17 -0
- data/sig/{_private/stoplight → stoplight}/domain/config.rbs +28 -24
- data/sig/{_private/stoplight → stoplight}/domain/error_tracking_policy.rbs +4 -0
- data/sig/{_private/stoplight → stoplight}/domain/failure.rbs +2 -0
- data/sig/stoplight/domain/id.rbs +7 -0
- data/sig/stoplight/domain/light.rbs +39 -0
- data/sig/{_private/stoplight → stoplight}/domain/light_info.rbs +1 -5
- data/sig/stoplight/domain/lock_control.rbs +16 -0
- data/sig/stoplight/domain/matcher_validator.rbs +11 -0
- data/sig/{_private/stoplight → stoplight}/domain/ports/clock.rbs +6 -0
- data/sig/stoplight/domain/ports/data_store.rbs +9 -0
- data/sig/stoplight/domain/ports/error_notifier.rbs +12 -0
- data/sig/stoplight/domain/ports/exception_matcher.rbs +10 -0
- data/sig/{_private/stoplight → stoplight}/domain/ports/metrics_store.rbs +2 -2
- data/sig/stoplight/domain/ports/registry.rbs +13 -0
- data/sig/{_private/stoplight → stoplight}/domain/ports/run_strategy.rbs +2 -1
- data/sig/stoplight/domain/ports/state_transition_notifier.rbs +18 -0
- data/sig/stoplight/domain/ports/telemetry.rbs +28 -0
- data/sig/stoplight/domain/ports/telemetry_publisher.rbs +14 -0
- data/sig/{_private/stoplight → stoplight}/domain/ports/traffic_control.rbs +7 -0
- data/sig/{_private/stoplight → stoplight}/domain/ports/traffic_recovery.rbs +2 -3
- data/sig/stoplight/domain/strategies/green_run_strategy.rbs +22 -0
- data/sig/stoplight/domain/strategies/red_run_strategy.rbs +19 -0
- data/sig/{_private/stoplight → stoplight}/domain/strategies/yellow_run_strategy.rbs +23 -12
- data/sig/stoplight/domain/telemetry/bus.rbs +49 -0
- data/sig/stoplight/domain/telemetry/consumer.rbs +13 -0
- data/sig/stoplight/domain/telemetry/emitter.rbs +51 -0
- data/sig/stoplight/domain/telemetry/envelope.rbs +30 -0
- data/sig/stoplight/domain/telemetry/failure.rbs +23 -0
- data/sig/stoplight/domain/telemetry/light_registered.rbs +23 -0
- data/sig/stoplight/domain/telemetry/lock_changed.rbs +31 -0
- data/sig/stoplight/domain/telemetry/metrics.rbs +27 -0
- data/sig/stoplight/domain/telemetry/recovery_failed.rbs +36 -0
- data/sig/stoplight/domain/telemetry/recovery_probe_completed.rbs +29 -0
- data/sig/stoplight/domain/telemetry/recovery_started.rbs +26 -0
- data/sig/stoplight/domain/telemetry/recovery_succeeded.rbs +31 -0
- data/sig/stoplight/domain/telemetry/run_completed.rbs +38 -0
- data/sig/stoplight/domain/telemetry/run_recorder.rbs +27 -0
- data/sig/stoplight/domain/telemetry/settings.rbs +47 -0
- data/sig/stoplight/domain/telemetry/state_transitioned.rbs +11 -0
- data/sig/stoplight/domain/telemetry/subscription.rbs +9 -0
- data/sig/stoplight/domain/telemetry/traffic_breached.rbs +36 -0
- data/sig/stoplight/domain/telemetry/types.rbs +32 -0
- data/sig/{_private/stoplight → stoplight}/domain/tracker/recovery_probe.rbs +10 -6
- data/sig/{_private/stoplight → stoplight}/domain/tracker/request.rbs +3 -3
- data/sig/{_private/stoplight → stoplight}/domain/traffic_control/consecutive_errors.rbs +2 -0
- data/sig/{_private/stoplight → stoplight}/domain/traffic_control/error_rate.rbs +3 -2
- data/sig/{_private/stoplight → stoplight}/domain/traffic_recovery/consecutive_successes.rbs +2 -0
- data/sig/stoplight/domain/types.rbs +25 -0
- data/sig/stoplight/error.rbs +8 -0
- data/sig/stoplight/generators/rails_generators_base.rbs +11 -0
- data/sig/stoplight/infrastructure/config_serializer.rbs +12 -0
- data/sig/stoplight/infrastructure/fail_safe/error_notifier.rbs +13 -0
- data/sig/{_private/stoplight → stoplight}/infrastructure/fail_safe/storage/metrics.rbs +2 -2
- data/sig/{_private/stoplight → stoplight}/infrastructure/fail_safe/storage/recovery_lock.rbs +2 -2
- data/sig/stoplight/infrastructure/fail_safe/storage/registry.rbs +23 -0
- data/sig/{_private/stoplight → stoplight}/infrastructure/fail_safe/storage/state.rbs +4 -4
- data/sig/stoplight/infrastructure/memory/storage/registry.rbs +13 -0
- data/sig/{_private/stoplight → stoplight}/infrastructure/memory/storage/state.rbs +3 -3
- data/sig/{_private/stoplight → stoplight}/infrastructure/memory/storage/unbounded_metrics.rbs +7 -7
- data/sig/stoplight/infrastructure/memory/storage/window_metrics/sliding_window.rbs +27 -0
- data/sig/{_private/stoplight → stoplight}/infrastructure/memory/storage/window_metrics.rbs +7 -7
- data/sig/stoplight/infrastructure/notifier/fail_safe.rbs +15 -0
- data/sig/{_private/stoplight → stoplight}/infrastructure/notifier/generic.rbs +1 -1
- data/sig/{_private/stoplight → stoplight}/infrastructure/notifier/io.rbs +1 -1
- data/sig/{_private/stoplight → stoplight}/infrastructure/notifier/logger.rbs +1 -1
- data/sig/stoplight/infrastructure/redis/key.rbs +10 -0
- data/sig/{_private/stoplight → stoplight}/infrastructure/redis/storage/recovery_lock.rbs +2 -2
- data/sig/stoplight/infrastructure/redis/storage/registry.rbs +27 -0
- data/sig/stoplight/infrastructure/redis/storage/scripting.rbs +34 -0
- data/sig/{_private/stoplight → stoplight}/infrastructure/redis/storage/state.rbs +4 -4
- data/sig/{_private/stoplight → stoplight}/infrastructure/redis/storage/unbounded_metrics.rbs +8 -1
- data/sig/stoplight/infrastructure/redis/storage/window_metrics.rbs +35 -0
- data/sig/stoplight/infrastructure/types.rbs +6 -0
- data/sig/stoplight/notifier.rbs +1 -1
- data/sig/stoplight/ports/system.rbs +16 -10
- data/sig/stoplight/state.rbs +3 -3
- data/sig/stoplight/telemetry.rbs +17 -0
- data/sig/stoplight/types.rbs +9 -0
- data/sig/{_private/stoplight → stoplight}/wiring/config_compatibility_validator.rbs +2 -0
- data/sig/stoplight/wiring/default.rbs +26 -0
- data/sig/stoplight/wiring/default_configuration.rbs +39 -0
- data/sig/stoplight/wiring/external_caller.rbs +13 -0
- data/sig/stoplight/wiring/fail_safe_config.rbs +7 -0
- data/sig/stoplight/wiring/global_state.rbs +36 -0
- data/sig/{_private/stoplight/wiring/light_factory → stoplight/wiring/light_configuration_dsl}/traffic_control_dsl.rbs +1 -1
- data/sig/{_private/stoplight/wiring/light_factory → stoplight/wiring/light_configuration_dsl}/traffic_recovery_dsl.rbs +1 -1
- data/sig/stoplight/wiring/light_configuration_dsl.rbs +38 -0
- data/sig/stoplight/wiring/light_factory.rbs +78 -0
- data/sig/stoplight/wiring/notifier_bridge.rbs +15 -0
- data/sig/stoplight/wiring/notifier_factory.rbs +10 -0
- data/sig/{_private/stoplight → stoplight}/wiring/redis/backend.rbs +6 -6
- data/sig/stoplight/wiring/system/storage.rbs +35 -0
- data/sig/stoplight/wiring/system.rbs +30 -0
- data/sig/stoplight/wiring/system_configuration_dsl.rbs +39 -0
- data/sig/stoplight/wiring/types.rbs +6 -0
- data/sig/stoplight.rbs +37 -54
- metadata +190 -143
- data/lib/stoplight/admin/actions/lock_all_green.rb +0 -18
- data/lib/stoplight/admin/actions/lock_green.rb +0 -23
- data/lib/stoplight/admin/actions/lock_red.rb +0 -23
- data/lib/stoplight/admin/lights_repository/light.rb +0 -171
- data/lib/stoplight/admin/lights_repository.rb +0 -87
- data/lib/stoplight/domain/light/configuration_builder_interface.rb +0 -236
- data/lib/stoplight/infrastructure/fail_safe/data_store.rb +0 -152
- data/lib/stoplight/infrastructure/memory/data_store/metrics.rb +0 -27
- data/lib/stoplight/infrastructure/memory/data_store/recovery_lock_store.rb +0 -52
- data/lib/stoplight/infrastructure/memory/data_store/recovery_lock_token.rb +0 -17
- data/lib/stoplight/infrastructure/memory/data_store/sliding_window.rb +0 -74
- data/lib/stoplight/infrastructure/memory/data_store/state.rb +0 -21
- data/lib/stoplight/infrastructure/memory/data_store.rb +0 -342
- data/lib/stoplight/infrastructure/redis/data_store/lua_scripts/get_metrics.lua +0 -26
- data/lib/stoplight/infrastructure/redis/data_store/lua_scripts/record_failure.lua +0 -36
- data/lib/stoplight/infrastructure/redis/data_store/lua_scripts/record_recovery_probe_failure.lua +0 -27
- data/lib/stoplight/infrastructure/redis/data_store/lua_scripts/record_recovery_probe_success.lua +0 -23
- data/lib/stoplight/infrastructure/redis/data_store/lua_scripts/record_success.lua +0 -35
- data/lib/stoplight/infrastructure/redis/data_store/lua_scripts/release_lock.lua +0 -6
- data/lib/stoplight/infrastructure/redis/data_store/lua_scripts/transition_to_green.lua +0 -10
- data/lib/stoplight/infrastructure/redis/data_store/lua_scripts/transition_to_red.lua +0 -10
- data/lib/stoplight/infrastructure/redis/data_store/lua_scripts/transition_to_yellow.lua +0 -9
- data/lib/stoplight/infrastructure/redis/data_store/recovery_lock_store.rb +0 -60
- data/lib/stoplight/infrastructure/redis/data_store/recovery_lock_token.rb +0 -28
- data/lib/stoplight/infrastructure/redis/data_store/scripting.rb +0 -73
- data/lib/stoplight/infrastructure/redis/data_store.rb +0 -516
- data/lib/stoplight/infrastructure/redis/storage/key_space.rb +0 -51
- data/lib/stoplight/infrastructure/storage/compatibility_metrics.rb +0 -41
- data/lib/stoplight/infrastructure/storage/compatibility_recovery_lock.rb +0 -33
- data/lib/stoplight/infrastructure/storage/compatibility_recovery_metrics.rb +0 -47
- data/lib/stoplight/infrastructure/storage/compatibility_state.rb +0 -44
- data/lib/stoplight/wiring/light_builder.rb +0 -198
- data/lib/stoplight/wiring/notifier_factory.rb +0 -26
- data/lib/stoplight/wiring/system/light_builder.rb +0 -47
- data/lib/stoplight/wiring/system/light_factory.rb +0 -64
- data/sig/_private/stoplight/domain/light.rbs +0 -25
- data/sig/_private/stoplight/domain/ports/data_store.rbs +0 -76
- data/sig/_private/stoplight/domain/ports/light_factory.rbs +0 -80
- data/sig/_private/stoplight/domain/strategies/green_run_strategy.rbs +0 -17
- data/sig/_private/stoplight/domain/strategies/red_run_strategy.rbs +0 -17
- data/sig/_private/stoplight/domain/tracker/base.rbs +0 -8
- data/sig/_private/stoplight/infrastructure/fail_safe/data_store.rbs +0 -26
- data/sig/_private/stoplight/infrastructure/memory/data_store/metrics.rbs +0 -25
- data/sig/_private/stoplight/infrastructure/memory/data_store/recovery_lock_store.rbs +0 -19
- data/sig/_private/stoplight/infrastructure/memory/data_store/recovery_lock_token.rbs +0 -17
- data/sig/_private/stoplight/infrastructure/memory/data_store/sliding_window.rbs +0 -27
- data/sig/_private/stoplight/infrastructure/memory/data_store/state.rbs +0 -17
- data/sig/_private/stoplight/infrastructure/memory/data_store.rbs +0 -30
- data/sig/_private/stoplight/infrastructure/notifier/fail_safe.rbs +0 -17
- data/sig/_private/stoplight/infrastructure/redis/data_store/recovery_lock_store.rbs +0 -24
- data/sig/_private/stoplight/infrastructure/redis/data_store/recovery_lock_token.rbs +0 -21
- data/sig/_private/stoplight/infrastructure/redis/data_store/scripting.rbs +0 -34
- data/sig/_private/stoplight/infrastructure/redis/data_store.rbs +0 -67
- data/sig/_private/stoplight/infrastructure/redis/storage/key_space.rbs +0 -19
- data/sig/_private/stoplight/infrastructure/redis/storage/scripting.rbs +0 -13
- data/sig/_private/stoplight/infrastructure/redis/storage/window_metrics.rbs +0 -34
- data/sig/_private/stoplight/infrastructure/storage/compatibility_metrics.rbs +0 -17
- data/sig/_private/stoplight/infrastructure/storage/compatibility_recovery_lock.rbs +0 -13
- data/sig/_private/stoplight/infrastructure/storage/compatibility_recovery_metrics.rbs +0 -14
- data/sig/_private/stoplight/infrastructure/storage/compatibility_state.rbs +0 -14
- data/sig/_private/stoplight/system/light_builder.rbs +0 -23
- data/sig/_private/stoplight/system/light_factory.rbs +0 -17
- data/sig/_private/stoplight/types.rbs +0 -6
- data/sig/_private/stoplight/wiring/configuration_dsl.rbs +0 -43
- data/sig/_private/stoplight/wiring/default.rbs +0 -26
- data/sig/_private/stoplight/wiring/default_configuration.rbs +0 -29
- data/sig/_private/stoplight/wiring/light_builder.rbs +0 -48
- data/sig/_private/stoplight/wiring/light_factory.rbs +0 -16
- data/sig/_private/stoplight/wiring/notifier_factory.rbs +0 -10
- data/sig/_private/stoplight/wiring/system.rbs +0 -15
- data/sig/_private/stoplight.rbs +0 -48
- data/sig/stoplight/data_store.rbs +0 -19
- data/sig/stoplight/ports/configuration.rbs +0 -19
- data/sig/stoplight/ports/exception_matcher.rbs +0 -8
- data/sig/stoplight/ports/light.rbs +0 -12
- data/sig/stoplight/ports/light_info.rbs +0 -5
- data/sig/stoplight/ports/state_transition_notifier.rbs +0 -15
- /data/sig/{_private/stoplight → stoplight}/common/deprecations.rbs +0 -0
- /data/sig/{_private/stoplight → stoplight}/domain/compatibility_result.rbs +0 -0
- /data/sig/{_private/stoplight → stoplight}/domain/metrics_snapshot.rbs +0 -0
- /data/sig/{_private/stoplight → stoplight}/domain/ports/recovery_lock_store.rbs +0 -0
- /data/sig/{_private/stoplight → stoplight}/domain/ports/recovery_lock_token.rbs +0 -0
- /data/sig/{_private/stoplight → stoplight}/domain/ports/state_store.rbs +0 -0
- /data/sig/{_private/stoplight → stoplight}/domain/state_snapshot.rbs +0 -0
- /data/sig/{_private/stoplight → stoplight}/domain/storage/recovery_lock_token.rbs +0 -0
- /data/sig/{_private/stoplight → stoplight}/domain/traffic_recovery.rbs +0 -0
- /data/sig/{_private → stoplight}/generators/stoplight/install/install_generator.rbs +0 -0
- /data/sig/{_private/stoplight → stoplight}/infrastructure/fail_safe/storage/recovery_lock_token.rbs +0 -0
- /data/sig/{_private/stoplight → stoplight}/infrastructure/memory/storage/recovery_lock.rbs +0 -0
- /data/sig/{_private/stoplight → stoplight}/infrastructure/memory/storage/recovery_metrics.rbs +0 -0
- /data/sig/{_private/stoplight → stoplight}/infrastructure/redis/storage/metrics.rbs +0 -0
- /data/sig/{_private/stoplight → stoplight}/infrastructure/redis/storage/recovery_metrics.rbs +0 -0
- /data/sig/{_private/stoplight → stoplight}/infrastructure/system_clock.rbs +0 -0
- /data/sig/{_private/stoplight → stoplight}/wiring/data_store_backend.rbs +0 -0
- /data/sig/{_private/stoplight → stoplight}/wiring/default_config.rbs +0 -0
- /data/sig/{_private/stoplight → stoplight}/wiring/memory/backend.rbs +0 -0
- /data/sig/{_private/stoplight → stoplight}/wiring/storage_set.rbs +0 -0
- /data/sig/{_private/stoplight → stoplight}/wiring/storage_set_builder.rbs +0 -0
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
module Stoplight
|
|
4
4
|
module Wiring
|
|
5
|
-
class
|
|
5
|
+
class SystemConfigurationDsl
|
|
6
6
|
def initialize(
|
|
7
|
-
name
|
|
7
|
+
name,
|
|
8
8
|
cool_off_time: T.undefined,
|
|
9
9
|
threshold: T.undefined,
|
|
10
10
|
recovery_threshold: T.undefined,
|
|
@@ -17,15 +17,16 @@ module Stoplight
|
|
|
17
17
|
traffic_control: T.undefined,
|
|
18
18
|
traffic_recovery: T.undefined
|
|
19
19
|
)
|
|
20
|
-
@name = name
|
|
20
|
+
@name = name.to_s
|
|
21
|
+
@id = Domain::Id.for(@name)
|
|
21
22
|
@cool_off_time = cool_off_time
|
|
22
23
|
@threshold = threshold
|
|
23
24
|
@recovery_threshold = recovery_threshold
|
|
24
25
|
@window_size = window_size
|
|
25
|
-
@tracked_errors = tracked_errors
|
|
26
|
-
@skipped_errors = skipped_errors
|
|
27
|
-
@traffic_control = traffic_control
|
|
28
|
-
@traffic_recovery = traffic_recovery
|
|
26
|
+
@tracked_errors = (tracked_errors.is_a?(Undefined) || tracked_errors.is_a?(Array)) ? tracked_errors : [tracked_errors]
|
|
27
|
+
@skipped_errors = (skipped_errors.is_a?(Undefined) || skipped_errors.is_a?(Array)) ? skipped_errors : [skipped_errors]
|
|
28
|
+
@traffic_control = traffic_control.is_a?(Undefined) ? traffic_control : LightConfigurationDsl::TrafficControlDsl.call(traffic_control)
|
|
29
|
+
@traffic_recovery = traffic_recovery.is_a?(Undefined) ? traffic_recovery : LightConfigurationDsl::TrafficRecoveryDsl.call(traffic_recovery)
|
|
29
30
|
@error_notifier = error_notifier
|
|
30
31
|
@data_store = data_store
|
|
31
32
|
@notifiers = notifiers
|
|
@@ -34,6 +35,7 @@ module Stoplight
|
|
|
34
35
|
def configure!(default_config)
|
|
35
36
|
ConfigCompatibilityValidator.call(
|
|
36
37
|
config: default_config.with(
|
|
38
|
+
id: @id,
|
|
37
39
|
name:,
|
|
38
40
|
cool_off_time:,
|
|
39
41
|
threshold:,
|
|
@@ -60,42 +62,10 @@ module Stoplight
|
|
|
60
62
|
attr_reader :error_notifier
|
|
61
63
|
attr_reader :data_store
|
|
62
64
|
attr_reader :notifiers
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
value
|
|
68
|
-
else
|
|
69
|
-
Array(value)
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def skipped_errors
|
|
74
|
-
value = @skipped_errors
|
|
75
|
-
if value.is_a?(Undefined)
|
|
76
|
-
value
|
|
77
|
-
else
|
|
78
|
-
Array(value)
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def traffic_control
|
|
83
|
-
value = @traffic_control
|
|
84
|
-
if value.is_a?(Undefined)
|
|
85
|
-
value
|
|
86
|
-
else
|
|
87
|
-
LightFactory::TrafficControlDsl.call(value)
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
def traffic_recovery
|
|
92
|
-
value = @traffic_recovery
|
|
93
|
-
if value.is_a?(Undefined)
|
|
94
|
-
value
|
|
95
|
-
else
|
|
96
|
-
LightFactory::TrafficRecoveryDsl.call(value)
|
|
97
|
-
end
|
|
98
|
-
end
|
|
65
|
+
attr_reader :tracked_errors
|
|
66
|
+
attr_reader :skipped_errors
|
|
67
|
+
attr_reader :traffic_control
|
|
68
|
+
attr_reader :traffic_recovery
|
|
99
69
|
end
|
|
100
70
|
end
|
|
101
71
|
end
|
data/lib/stoplight.rb
CHANGED
|
@@ -21,13 +21,11 @@ module Stoplight # rubocop:disable Style/Documentation
|
|
|
21
21
|
|
|
22
22
|
CONFIG_MUTEX = Mutex.new
|
|
23
23
|
private_constant :CONFIG_MUTEX
|
|
24
|
-
@systems = Concurrent::Map.new
|
|
25
24
|
|
|
26
25
|
class << self
|
|
27
26
|
# Configures the Stoplight library.
|
|
28
27
|
#
|
|
29
28
|
# This method allows you to set up the library's configuration using a block.
|
|
30
|
-
# It raises an error if called more than once.
|
|
31
29
|
# @param trust_me_im_an_engineer [Boolean]
|
|
32
30
|
# @yield [config] Provides a configuration object to the block.
|
|
33
31
|
# @yieldparam config [Stoplight::Wiring::DefaultConfiguration] The configuration object.
|
|
@@ -48,8 +46,7 @@ module Stoplight # rubocop:disable Style/Documentation
|
|
|
48
46
|
# it will not be possible to change the configuration of existing circuit breakers. If you do so, the method
|
|
49
47
|
# produces a warning:
|
|
50
48
|
#
|
|
51
|
-
# "Stoplight reconfigured. Existing circuit breakers will not see
|
|
52
|
-
# configuration: ...f
|
|
49
|
+
# "Stoplight reconfigured. Existing circuit breakers will not see new configuration"
|
|
53
50
|
#
|
|
54
51
|
# If you really know what you are doing, you can pass the +trust_me_im_an_engineer+ parameter as +true+ to
|
|
55
52
|
# suppress this warning, which could be useful in test environments.
|
|
@@ -59,86 +56,42 @@ module Stoplight # rubocop:disable Style/Documentation
|
|
|
59
56
|
configuration = Wiring::DefaultConfiguration.new
|
|
60
57
|
yield configuration if block_given?
|
|
61
58
|
|
|
62
|
-
|
|
63
|
-
@default_config = default_config
|
|
64
|
-
@default_light_factory = Wiring::LightFactory.new(config: default_config)
|
|
59
|
+
@state = Wiring::GlobalState.new(default_config: configuration.to_config!)
|
|
65
60
|
end
|
|
66
61
|
end
|
|
67
62
|
|
|
68
|
-
#
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
data_store: T.undefined,
|
|
78
|
-
error_notifier: T.undefined,
|
|
79
|
-
notifiers: T.undefined,
|
|
80
|
-
traffic_control: T.undefined,
|
|
81
|
-
traffic_recovery: T.undefined
|
|
82
|
-
)
|
|
83
|
-
Wiring::LightFactory.new(config: Wiring::DefaultConfig).build_with(
|
|
84
|
-
name: "__stoplight__#{name}",
|
|
85
|
-
cool_off_time:,
|
|
86
|
-
threshold:,
|
|
87
|
-
recovery_threshold:,
|
|
88
|
-
window_size:,
|
|
89
|
-
tracked_errors:,
|
|
90
|
-
skipped_errors:,
|
|
91
|
-
data_store:,
|
|
92
|
-
error_notifier:,
|
|
93
|
-
notifiers:,
|
|
94
|
-
traffic_control:,
|
|
95
|
-
traffic_recovery:
|
|
96
|
-
)
|
|
97
|
-
end
|
|
63
|
+
# Registers a Light with the given configuration.
|
|
64
|
+
#
|
|
65
|
+
# If a light with this name is already registered, returns it. If the given settings
|
|
66
|
+
# differ from the existing registration, raises +Stoplight::Error::ConfigurationError+.
|
|
67
|
+
# #
|
|
68
|
+
# @example
|
|
69
|
+
# Stoplight.register("stripe", threshold: 5, cool_off_time: 60)
|
|
70
|
+
#
|
|
71
|
+
def register(...) = state.default_system.register(...)
|
|
98
72
|
|
|
99
|
-
#
|
|
73
|
+
# Returns a Light previously registered.
|
|
100
74
|
#
|
|
101
|
-
# @
|
|
102
|
-
#
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
traffic_recovery: T.undefined
|
|
116
|
-
)
|
|
117
|
-
__stoplight__default_light_factory.build_with(
|
|
118
|
-
name:,
|
|
119
|
-
cool_off_time:,
|
|
120
|
-
threshold:,
|
|
121
|
-
recovery_threshold:,
|
|
122
|
-
window_size:,
|
|
123
|
-
tracked_errors:,
|
|
124
|
-
skipped_errors:,
|
|
125
|
-
data_store:,
|
|
126
|
-
error_notifier:,
|
|
127
|
-
notifiers:,
|
|
128
|
-
traffic_control:,
|
|
129
|
-
traffic_recovery:
|
|
130
|
-
)
|
|
131
|
-
end
|
|
75
|
+
# @raise [Stoplight::Error::UnregisteredLightError] if no light was registered under +name+
|
|
76
|
+
#
|
|
77
|
+
# @example
|
|
78
|
+
# Stoplight.register("stripe", threshold: 5)
|
|
79
|
+
# Stoplight.light("stripe")
|
|
80
|
+
#
|
|
81
|
+
def light(...) = state.default_system.light(...)
|
|
82
|
+
|
|
83
|
+
# Returns the consumer side of the default system's telemetry bus.
|
|
84
|
+
#
|
|
85
|
+
# @example
|
|
86
|
+
# Stoplight.telemetry.subscribe(Stoplight::Telemetry::RunCompleted) { |envelope| track(envelope) }
|
|
87
|
+
#
|
|
88
|
+
def telemetry = state.default_system.telemetry
|
|
132
89
|
|
|
133
90
|
# Creates a new named system with the given configuration.
|
|
134
91
|
#
|
|
135
92
|
# Systems are composition roots that own infrastructure (data store, notifiers)
|
|
136
93
|
# and enforce configuration consistency for all lights created within them.
|
|
137
94
|
#
|
|
138
|
-
# @param name [String] Unique identifier for the system
|
|
139
|
-
# @param settings [Hash] Configuration options that override global defaults.
|
|
140
|
-
# @see Stoplight() documentation
|
|
141
|
-
#
|
|
142
95
|
# @return [Stoplight::Wiring::System] A new system instance.
|
|
143
96
|
#
|
|
144
97
|
# @raise [ArgumentError] If a system with the given name already exists.
|
|
@@ -147,55 +100,14 @@ module Stoplight # rubocop:disable Style/Documentation
|
|
|
147
100
|
# for repeated access. Calling this method twice with the same name raises an error.
|
|
148
101
|
#
|
|
149
102
|
# @example Creating a system for payment services
|
|
150
|
-
# Payments = Stoplight.
|
|
103
|
+
# Payments = Stoplight.register_system("Payments", threshold: 3, cool_off_time: 30)
|
|
104
|
+
# Payments.register("stripe")
|
|
151
105
|
# Payments.light("stripe").run { process_payment }
|
|
152
106
|
#
|
|
153
107
|
# @example Isolated system with dedicated data store
|
|
154
|
-
# Analytics = Stoplight.
|
|
108
|
+
# Analytics = Stoplight.register_system("Analytics", data_store: analytics_redis)
|
|
155
109
|
#
|
|
156
|
-
|
|
157
|
-
def __stoplight__system(
|
|
158
|
-
name,
|
|
159
|
-
cool_off_time: T.undefined,
|
|
160
|
-
threshold: T.undefined,
|
|
161
|
-
recovery_threshold: T.undefined,
|
|
162
|
-
window_size: T.undefined,
|
|
163
|
-
tracked_errors: T.undefined,
|
|
164
|
-
skipped_errors: T.undefined,
|
|
165
|
-
data_store: T.undefined,
|
|
166
|
-
error_notifier: T.undefined,
|
|
167
|
-
notifiers: T.undefined,
|
|
168
|
-
traffic_control: T.undefined,
|
|
169
|
-
traffic_recovery: T.undefined
|
|
170
|
-
)
|
|
171
|
-
ensure_configured
|
|
172
|
-
|
|
173
|
-
systems.compute(name.to_s) do |existing_system|
|
|
174
|
-
if existing_system
|
|
175
|
-
raise ArgumentError, "system `#{name}` is already in use"
|
|
176
|
-
else
|
|
177
|
-
Wiring::System.new(
|
|
178
|
-
config: Wiring::ConfigurationDsl.new(
|
|
179
|
-
name: name.to_s,
|
|
180
|
-
cool_off_time:,
|
|
181
|
-
threshold:,
|
|
182
|
-
recovery_threshold:,
|
|
183
|
-
window_size:,
|
|
184
|
-
tracked_errors:,
|
|
185
|
-
skipped_errors:,
|
|
186
|
-
traffic_control:,
|
|
187
|
-
traffic_recovery:,
|
|
188
|
-
data_store:,
|
|
189
|
-
error_notifier:,
|
|
190
|
-
notifiers:
|
|
191
|
-
).configure!(default_config)
|
|
192
|
-
)
|
|
193
|
-
end
|
|
194
|
-
end
|
|
195
|
-
end
|
|
196
|
-
|
|
197
|
-
private attr_reader :systems
|
|
198
|
-
private def default_config = T.must(@default_config)
|
|
110
|
+
def register_system(...) = state.register_system(...)
|
|
199
111
|
|
|
200
112
|
# Resets Stoplight to an unconfigured state.
|
|
201
113
|
#
|
|
@@ -221,28 +133,16 @@ module Stoplight # rubocop:disable Style/Documentation
|
|
|
221
133
|
#
|
|
222
134
|
# @api private
|
|
223
135
|
def __stoplight__reset!
|
|
224
|
-
@
|
|
225
|
-
@default_config = nil
|
|
226
|
-
@default_light_factory = nil
|
|
227
|
-
@configured = nil
|
|
228
|
-
end
|
|
229
|
-
|
|
230
|
-
# Retrieves the current default dependencies.
|
|
231
|
-
#
|
|
232
|
-
# @return [Stoplight::Domain::LightFactory]
|
|
233
|
-
# @api private
|
|
234
|
-
def __stoplight__default_light_factory
|
|
235
|
-
ensure_configured
|
|
236
|
-
T.must(@default_light_factory)
|
|
136
|
+
@state = nil
|
|
237
137
|
end
|
|
238
138
|
|
|
239
|
-
def __stoplight__default_configuration
|
|
240
|
-
|
|
241
|
-
T.must(@default_config)
|
|
242
|
-
end
|
|
139
|
+
def __stoplight__default_configuration = state.default_config
|
|
140
|
+
def __stoplight__default_system = state.default_system
|
|
243
141
|
|
|
244
142
|
# @api private
|
|
245
143
|
private def ensure_configured
|
|
144
|
+
return if configured?
|
|
145
|
+
|
|
246
146
|
CONFIG_MUTEX.synchronize do
|
|
247
147
|
configure unless configured?
|
|
248
148
|
end
|
|
@@ -253,38 +153,36 @@ module Stoplight # rubocop:disable Style/Documentation
|
|
|
253
153
|
warn "Stoplight reconfigured. Existing circuit breakers will not see new configuration"
|
|
254
154
|
end
|
|
255
155
|
yield
|
|
256
|
-
@configured = true
|
|
257
156
|
end
|
|
258
157
|
|
|
259
158
|
private def configured?
|
|
260
|
-
@
|
|
159
|
+
@state != nil
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
private def state
|
|
163
|
+
ensure_configured
|
|
164
|
+
T.must(@state)
|
|
261
165
|
end
|
|
262
166
|
end
|
|
263
167
|
end
|
|
264
168
|
|
|
265
|
-
# Creates a new Stoplight circuit
|
|
169
|
+
# Creates a new Stoplight circuit breaker with the given name and settings.
|
|
266
170
|
#
|
|
267
171
|
# @param name [String] The name of the circuit breaker.
|
|
268
|
-
# @param
|
|
269
|
-
#
|
|
270
|
-
#
|
|
271
|
-
#
|
|
272
|
-
#
|
|
273
|
-
#
|
|
274
|
-
# @option settings [Array<StandardError>] :tracked_errors A list of errors to track.
|
|
275
|
-
# @option settings [Array<Exception>] :skipped_errors A list of errors to skip.
|
|
276
|
-
# @option settings [Symbol, {Symbol, Hash{Symbol, any}}] :traffic_control The
|
|
277
|
-
# traffic control strategy to use.
|
|
172
|
+
# @param cool_off_time The time to wait before resetting the circuit breaker, in whole seconds, at least 1.
|
|
173
|
+
# @param threshold The failure threshold to trip the circuit breaker.
|
|
174
|
+
# @param window_size The size of the rolling window for failure tracking, in whole seconds, at least 1.
|
|
175
|
+
# @param tracked_errors A list of errors to track.
|
|
176
|
+
# @param skipped_errors A list of errors to skip.
|
|
177
|
+
# @param traffic_control The traffic control strategy to use.
|
|
278
178
|
#
|
|
279
179
|
# @return [Stoplight::Light] A new circuit breaker instance.
|
|
280
180
|
# @raise [ArgumentError] If an unknown option is provided in the settings.
|
|
181
|
+
# @raise [Stoplight::Error::ConfigurationError] If a setting is invalid or conflicts with an earlier registration.
|
|
281
182
|
#
|
|
282
183
|
# @example configure circuit breaker behavior
|
|
283
184
|
# light = Stoplight("Payment API", window_size: 300, threshold: 5, cool_off_time: 60)
|
|
284
185
|
#
|
|
285
|
-
# @example configure data store
|
|
286
|
-
# light = Stoplight("Payment API", data_store: Stoplight::DataStore::Redis.new(redis_client))
|
|
287
|
-
#
|
|
288
186
|
# In the example below, the +TimeoutError+ and +NetworkError+ exceptions
|
|
289
187
|
# will be counted towards the threshold for moving the circuit breaker into the red state.
|
|
290
188
|
# If not configured, the default tracked error is +StandardError+.
|
|
@@ -306,46 +204,4 @@ end
|
|
|
306
204
|
# # When 66.6% error rate reached withing a sliding 5 minute window, the circuit breaker will trip.
|
|
307
205
|
# light = Stoplight("Payment API", traffic_control: :error_rate, threshold: 0.666, window_size: 300)
|
|
308
206
|
#
|
|
309
|
-
def Stoplight(
|
|
310
|
-
name,
|
|
311
|
-
cool_off_time: Stoplight::T.undefined,
|
|
312
|
-
threshold: Stoplight::T.undefined,
|
|
313
|
-
recovery_threshold: Stoplight::T.undefined,
|
|
314
|
-
window_size: Stoplight::T.undefined,
|
|
315
|
-
tracked_errors: Stoplight::T.undefined,
|
|
316
|
-
skipped_errors: Stoplight::T.undefined,
|
|
317
|
-
data_store: Stoplight::T.undefined,
|
|
318
|
-
error_notifier: Stoplight::T.undefined,
|
|
319
|
-
notifiers: Stoplight::T.undefined,
|
|
320
|
-
traffic_control: Stoplight::T.undefined,
|
|
321
|
-
traffic_recovery: Stoplight::T.undefined
|
|
322
|
-
) # rubocop:disable Naming/MethodName
|
|
323
|
-
Stoplight::Common::Deprecations.deprecate(<<~MSG) if error_notifier != Stoplight::T.undefined
|
|
324
|
-
Passing "error_notifier" to Stoplight('#{name}') is deprecated and will be removed in v6.0.0.
|
|
325
|
-
|
|
326
|
-
IMPORTANT: The `error_notifier` is NOT called for exceptions in your protected code.
|
|
327
|
-
It only reports internal Stoplight failures (e.g., Redis connection errors).
|
|
328
|
-
|
|
329
|
-
To fix: Move `error_notifier` to global configuration:
|
|
330
|
-
|
|
331
|
-
Stoplight.configure do |config|
|
|
332
|
-
config.error_notifier = ->(error) { Logger.warn(error) }
|
|
333
|
-
end
|
|
334
|
-
|
|
335
|
-
See: https://github.com/bolshakov/stoplight#error-notifiers
|
|
336
|
-
MSG
|
|
337
|
-
Stoplight.light(
|
|
338
|
-
name,
|
|
339
|
-
cool_off_time:,
|
|
340
|
-
threshold:,
|
|
341
|
-
recovery_threshold:,
|
|
342
|
-
window_size:,
|
|
343
|
-
tracked_errors:,
|
|
344
|
-
skipped_errors:,
|
|
345
|
-
data_store:,
|
|
346
|
-
error_notifier:,
|
|
347
|
-
notifiers:,
|
|
348
|
-
traffic_control:,
|
|
349
|
-
traffic_recovery:
|
|
350
|
-
)
|
|
351
|
-
end
|
|
207
|
+
def Stoplight(...) = Stoplight.register(...) # rubocop:disable Naming/MethodName
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
class Admin
|
|
3
|
+
module Actions
|
|
4
|
+
class Lock < Action
|
|
5
|
+
@config_registry: ConfigRegistry
|
|
6
|
+
@storage: Wiring::System::Storage
|
|
7
|
+
|
|
8
|
+
def initialize: (
|
|
9
|
+
config_registry: ConfigRegistry,
|
|
10
|
+
storage: Wiring::System::Storage
|
|
11
|
+
) -> void
|
|
12
|
+
|
|
13
|
+
def call: (light_id: String, color: Domain::color) -> void
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
class Admin
|
|
3
|
+
module Actions
|
|
4
|
+
class LockAll < Action
|
|
5
|
+
@config_registry: ConfigRegistry
|
|
6
|
+
@storage: Wiring::System::Storage
|
|
7
|
+
|
|
8
|
+
def initialize: (
|
|
9
|
+
config_registry: ConfigRegistry,
|
|
10
|
+
storage: Wiring::System::Storage
|
|
11
|
+
) -> void
|
|
12
|
+
|
|
13
|
+
def call: (color: Domain::color)-> void
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Stoplight
|
|
4
|
+
class Admin
|
|
5
|
+
module Actions
|
|
6
|
+
# This action removes a light's metadata from Redis
|
|
7
|
+
class Remove < Action
|
|
8
|
+
@config_registry: ConfigRegistry
|
|
9
|
+
@storage: Wiring::System::Storage
|
|
10
|
+
@registry: Domain::_Registry
|
|
11
|
+
|
|
12
|
+
def initialize: (
|
|
13
|
+
config_registry: ConfigRegistry,
|
|
14
|
+
storage: Wiring::System::Storage,
|
|
15
|
+
registry: Domain::_Registry
|
|
16
|
+
) -> void
|
|
17
|
+
|
|
18
|
+
def call: (light_id: String) -> void
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Stoplight
|
|
4
|
+
class Admin
|
|
5
|
+
module Actions
|
|
6
|
+
class Stats < Action
|
|
7
|
+
@lights_stats: singleton(Stoplight::Admin::LightsStats)
|
|
8
|
+
@config_registry: ConfigRegistry
|
|
9
|
+
@storage: Wiring::System::Storage
|
|
10
|
+
|
|
11
|
+
# @param lights_stats [Class<Stoplight::Admin::LightsStats>]
|
|
12
|
+
def initialize: (
|
|
13
|
+
lights_stats: singleton(Stoplight::Admin::LightsStats),
|
|
14
|
+
config_registry: ConfigRegistry,
|
|
15
|
+
storage: Wiring::System::Storage,
|
|
16
|
+
) -> void
|
|
17
|
+
|
|
18
|
+
# @return [(Stoplight::Admin::LightView)]
|
|
19
|
+
def call: -> [
|
|
20
|
+
Array[LightView],
|
|
21
|
+
Hash[Symbol, Integer],
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
private def build_light: (Domain::Config) -> LightView
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
class Admin
|
|
3
|
+
module Actions
|
|
4
|
+
class Unlock < Action
|
|
5
|
+
@config_registry: ConfigRegistry
|
|
6
|
+
@storage: Wiring::System::Storage
|
|
7
|
+
|
|
8
|
+
def initialize: (
|
|
9
|
+
config_registry: ConfigRegistry,
|
|
10
|
+
storage: Wiring::System::Storage
|
|
11
|
+
) -> void
|
|
12
|
+
|
|
13
|
+
def call: (light_id: String) -> void
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
class Admin
|
|
3
|
+
class ConfigRegistry
|
|
4
|
+
@registry: Domain::_Registry
|
|
5
|
+
@system_config: Domain::Config
|
|
6
|
+
|
|
7
|
+
def initialize: (
|
|
8
|
+
registry: Domain::_Registry,
|
|
9
|
+
system_config: Domain::Config
|
|
10
|
+
) -> void
|
|
11
|
+
|
|
12
|
+
def all: -> Array[Domain::Config]
|
|
13
|
+
def find_by_id: (String) -> Domain::Config?
|
|
14
|
+
|
|
15
|
+
private
|
|
16
|
+
|
|
17
|
+
def deserialize_config: (Hash[String, untyped]) -> Domain::Config
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
class Admin
|
|
3
|
+
class Dependencies
|
|
4
|
+
@system: Wiring::System
|
|
5
|
+
@storage: Wiring::System::Storage
|
|
6
|
+
|
|
7
|
+
def initialize: (system: Wiring::System) -> void
|
|
8
|
+
def config_registry: -> ConfigRegistry
|
|
9
|
+
def stats_action: -> Actions::Stats
|
|
10
|
+
def unlock_action: -> Actions::Unlock
|
|
11
|
+
def lock_action: -> Actions::Lock
|
|
12
|
+
def lock_all_action: -> Actions::LockAll
|
|
13
|
+
def remove_action: -> Actions::Remove
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
class Admin
|
|
3
|
+
module Helpers : Sinatra::Base
|
|
4
|
+
COLORS: Array[Domain::color]
|
|
5
|
+
|
|
6
|
+
def dependencies: -> Dependencies
|
|
7
|
+
def system_url: (String system_id, String path) -> String
|
|
8
|
+
def asset_path: (String) -> String
|
|
9
|
+
def time_ago_in_words: (Time) -> String
|
|
10
|
+
def control_attributes: (String href, ?confirm: String?, ?verb: String?) -> String
|
|
11
|
+
def find_system: (String) -> Wiring::System
|
|
12
|
+
def current_system_id: -> String
|
|
13
|
+
def current_system: -> Wiring::System
|
|
14
|
+
def show_system_switcher?: -> bool
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
class Admin
|
|
3
|
+
class LightView
|
|
4
|
+
COLORS: Array[Domain::color]
|
|
5
|
+
|
|
6
|
+
attr_reader failures: Array[Domain::Failure]
|
|
7
|
+
|
|
8
|
+
@state_snapshot: Domain::StateSnapshot
|
|
9
|
+
@metrics_snapshot: Domain::MetricsSnapshot
|
|
10
|
+
@recovery_metrics_snapshot: Domain::MetricsSnapshot
|
|
11
|
+
@config: Domain::Config
|
|
12
|
+
@failures: Array[Domain::Failure]
|
|
13
|
+
|
|
14
|
+
def initialize: (
|
|
15
|
+
config: Domain::Config,
|
|
16
|
+
state_snapshot: Domain::StateSnapshot,
|
|
17
|
+
recovery_metrics_snapshot: Domain::MetricsSnapshot,
|
|
18
|
+
metrics_snapshot: Domain::MetricsSnapshot,
|
|
19
|
+
) -> void
|
|
20
|
+
|
|
21
|
+
def id: -> String
|
|
22
|
+
def color: -> Domain::color
|
|
23
|
+
def name: -> String
|
|
24
|
+
def state: -> Domain::state
|
|
25
|
+
def traffic_metric_label: -> String
|
|
26
|
+
def traffic_metric_value: -> String
|
|
27
|
+
def locked?: -> bool
|
|
28
|
+
def unlocked?: -> bool
|
|
29
|
+
def as_json: -> Hash[Symbol, _ToS]
|
|
30
|
+
def default_sort_key: -> Array[Comparable]
|
|
31
|
+
def last_check: -> Time?
|
|
32
|
+
private def duration_in_words: (Integer) -> String
|
|
33
|
+
def description_title: -> String
|
|
34
|
+
def description_message: -> String
|
|
35
|
+
def description_comment: -> String
|
|
36
|
+
def latest_failure: -> Domain::Failure?
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
class Admin
|
|
3
|
+
class LightsStats
|
|
4
|
+
EMPTY_STATS: Hash[Symbol, Integer]
|
|
5
|
+
|
|
6
|
+
attr_reader lights: Array[LightView]
|
|
7
|
+
@lights: Array[LightView]
|
|
8
|
+
|
|
9
|
+
def self.call: (Array[LightView]) -> Hash[Symbol, Integer]
|
|
10
|
+
|
|
11
|
+
def initialize: (Array[LightView]) -> void
|
|
12
|
+
|
|
13
|
+
def call: -> Hash[Symbol, Integer]
|
|
14
|
+
|
|
15
|
+
private
|
|
16
|
+
|
|
17
|
+
def size: -> Integer
|
|
18
|
+
|
|
19
|
+
def count_lights: (Domain::color)-> Integer
|
|
20
|
+
def count_red: -> Integer
|
|
21
|
+
def count_green: -> Integer
|
|
22
|
+
def count_yellow: -> Integer
|
|
23
|
+
|
|
24
|
+
def percent_lights: (Domain::color)-> Integer
|
|
25
|
+
def percent_green: -> Integer
|
|
26
|
+
def percent_red: -> Integer
|
|
27
|
+
def percent_yellow: -> Integer
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|