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
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
module Domain
|
|
3
|
+
module Telemetry
|
|
4
|
+
# The producer side of the bus. One per light, bound to its coordinates at construction time in
|
|
5
|
+
# wiring, responsible for building envelopes. Injected into strategies, trackers, and Light the same
|
|
6
|
+
# way notifiers are today.
|
|
7
|
+
class Emitter
|
|
8
|
+
@bus: _TelemetryPublisher
|
|
9
|
+
@clock: _Clock
|
|
10
|
+
@system_name: String
|
|
11
|
+
@light_name: String
|
|
12
|
+
@error_notifier: error_notifier
|
|
13
|
+
|
|
14
|
+
def initialize: (
|
|
15
|
+
bus: _TelemetryPublisher,
|
|
16
|
+
clock: _Clock,
|
|
17
|
+
system_name: String,
|
|
18
|
+
light_name: String,
|
|
19
|
+
error_notifier: error_notifier
|
|
20
|
+
) -> void
|
|
21
|
+
|
|
22
|
+
# True when any subscriber would receive this event class.
|
|
23
|
+
def subscribed?: (Telemetry::event_class) -> bool
|
|
24
|
+
|
|
25
|
+
# Lazily yields the event's payload only when the bus has subscribers for this event class, then stamps
|
|
26
|
+
# +occurred_at+ from the clock and publishes.
|
|
27
|
+
#
|
|
28
|
+
# Emitting an unwatched event class allocates nothing - no payload, no envelope.
|
|
29
|
+
#
|
|
30
|
+
# The leading class argument is what lets the per-class guard run before the payload exists. Each overload
|
|
31
|
+
# pins the block's return type to it, so a mismatch is a Steep error at the emission site.
|
|
32
|
+
#
|
|
33
|
+
# @example
|
|
34
|
+
# emitter.emit(Telemetry::RecoveryStarted) do
|
|
35
|
+
# RecoveryStarted.new(from_color: "red", to_color: "yellow", breached_at: Time.now)
|
|
36
|
+
# end
|
|
37
|
+
#
|
|
38
|
+
def emit: (singleton(RunCompleted)) { () -> RunCompleted } -> void
|
|
39
|
+
| (singleton(TrafficBreached)) { () -> TrafficBreached } -> void
|
|
40
|
+
| (singleton(RecoveryStarted)) { () -> RecoveryStarted } -> void
|
|
41
|
+
| (singleton(RecoverySucceeded)) { () -> RecoverySucceeded } -> void
|
|
42
|
+
| (singleton(RecoveryFailed)) { () -> RecoveryFailed } -> void
|
|
43
|
+
| (singleton(LockChanged)) { () -> LockChanged } -> void
|
|
44
|
+
| (singleton(RecoveryProbeCompleted)) { () -> RecoveryProbeCompleted } -> void
|
|
45
|
+
| (singleton(LightRegistered)) { () -> LightRegistered } -> void
|
|
46
|
+
|
|
47
|
+
private def notify_error: (StandardError) -> void
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
module Domain
|
|
3
|
+
module Telemetry
|
|
4
|
+
# Wraps every published event. Carries only what the emission site knows.
|
|
5
|
+
#
|
|
6
|
+
# Identity, sequencing, and transport-level enrichment (ids, host, app version, deploy), etc. belong to the
|
|
7
|
+
# exporter, which can attach them at delivery time.
|
|
8
|
+
class Envelope[out P < event] < Data
|
|
9
|
+
attr_reader system_name: String
|
|
10
|
+
attr_reader light_name: String
|
|
11
|
+
attr_reader occurred_at: Time
|
|
12
|
+
attr_reader payload: P
|
|
13
|
+
|
|
14
|
+
def self.new: [Q < event] (
|
|
15
|
+
system_name: String,
|
|
16
|
+
light_name: String,
|
|
17
|
+
occurred_at: Time,
|
|
18
|
+
payload: Q
|
|
19
|
+
) -> Envelope[Q]
|
|
20
|
+
|
|
21
|
+
def initialize: (
|
|
22
|
+
system_name: String,
|
|
23
|
+
light_name: String,
|
|
24
|
+
occurred_at: Time,
|
|
25
|
+
payload: P
|
|
26
|
+
) -> void
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
module Domain
|
|
3
|
+
module Telemetry
|
|
4
|
+
# Carries the live exception.
|
|
5
|
+
class Failure < Data
|
|
6
|
+
attr_reader exception: StandardError
|
|
7
|
+
# false when the exception matched skipped_errors: the light counted the run a success, but the caller still
|
|
8
|
+
# saw the exception.
|
|
9
|
+
attr_reader tracked: bool
|
|
10
|
+
|
|
11
|
+
def self.new: (
|
|
12
|
+
exception: StandardError,
|
|
13
|
+
tracked: bool
|
|
14
|
+
) -> instance
|
|
15
|
+
|
|
16
|
+
def initialize: (
|
|
17
|
+
exception: StandardError,
|
|
18
|
+
tracked: bool
|
|
19
|
+
) -> void
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
module Domain
|
|
3
|
+
module Telemetry
|
|
4
|
+
# Emitted once per (process instance, system, light): the cache-miss branch of System#light.
|
|
5
|
+
#
|
|
6
|
+
# Consumers deduplicate by (system_name, light_name) + settings content.
|
|
7
|
+
#
|
|
8
|
+
# Emitted by wiring through the light's own emitter, after the light is fully constructed and before it is
|
|
9
|
+
# returned to the caller - so on the bus it precedes every other event of that light.
|
|
10
|
+
class LightRegistered < Data
|
|
11
|
+
attr_reader settings: Settings
|
|
12
|
+
|
|
13
|
+
def self.new: (
|
|
14
|
+
settings: Settings
|
|
15
|
+
) -> instance
|
|
16
|
+
|
|
17
|
+
def initialize: (
|
|
18
|
+
settings: Settings
|
|
19
|
+
) -> void
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
module Domain
|
|
3
|
+
module Telemetry
|
|
4
|
+
# state_transitioned variant: manual lock override changed.
|
|
5
|
+
#
|
|
6
|
+
# Emitted even when the effective color is unchanged (from_color == to_color), so the lock timeline is complete.
|
|
7
|
+
class LockChanged < Data
|
|
8
|
+
include StateTransitioned
|
|
9
|
+
|
|
10
|
+
attr_reader from_color: color
|
|
11
|
+
attr_reader to_color: color
|
|
12
|
+
attr_reader from_state: state
|
|
13
|
+
attr_reader to_state: state
|
|
14
|
+
|
|
15
|
+
def self.new: (
|
|
16
|
+
from_color: color,
|
|
17
|
+
to_color: color,
|
|
18
|
+
from_state: state,
|
|
19
|
+
to_state: state,
|
|
20
|
+
) -> instance
|
|
21
|
+
|
|
22
|
+
def initialize: (
|
|
23
|
+
from_color: color,
|
|
24
|
+
to_color: color,
|
|
25
|
+
from_state: state,
|
|
26
|
+
to_state: state,
|
|
27
|
+
) -> void
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
module Domain
|
|
3
|
+
module Telemetry
|
|
4
|
+
# The serializable subset of MetricsSnapshot. successes/errors are nil for non-windowed metrics.
|
|
5
|
+
class Metrics < Data
|
|
6
|
+
attr_reader successes: Integer?
|
|
7
|
+
attr_reader errors: Integer?
|
|
8
|
+
attr_reader consecutive_errors: Integer
|
|
9
|
+
attr_reader consecutive_successes: Integer
|
|
10
|
+
|
|
11
|
+
def self.new: (
|
|
12
|
+
successes: Integer?,
|
|
13
|
+
errors: Integer?,
|
|
14
|
+
consecutive_errors: Integer,
|
|
15
|
+
consecutive_successes: Integer
|
|
16
|
+
) -> instance
|
|
17
|
+
|
|
18
|
+
def initialize: (
|
|
19
|
+
successes: Integer?,
|
|
20
|
+
errors: Integer?,
|
|
21
|
+
consecutive_errors: Integer,
|
|
22
|
+
consecutive_successes: Integer
|
|
23
|
+
) -> void
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
module Domain
|
|
3
|
+
module Telemetry
|
|
4
|
+
# state_transitioned variant: recovery policy sent the light back to red.
|
|
5
|
+
class RecoveryFailed < Data
|
|
6
|
+
include StateTransitioned
|
|
7
|
+
|
|
8
|
+
attr_reader from_color: yellow
|
|
9
|
+
attr_reader to_color: red
|
|
10
|
+
# Open set - the traffic-recovery policy self-identifies.
|
|
11
|
+
attr_reader policy: String
|
|
12
|
+
# Semantic nil: today's ConsecutiveSuccesses always has a triggering exception, but a future policy may fail
|
|
13
|
+
# a recovery without one (e.g. a deadline-based strategy).
|
|
14
|
+
attr_reader failure: Failure?
|
|
15
|
+
# Recovery metrics at the decision point.
|
|
16
|
+
attr_reader metrics: Metrics
|
|
17
|
+
|
|
18
|
+
def self.new: (
|
|
19
|
+
from_color: yellow,
|
|
20
|
+
to_color: red,
|
|
21
|
+
policy: String,
|
|
22
|
+
failure: Failure?,
|
|
23
|
+
metrics: Metrics
|
|
24
|
+
) -> instance
|
|
25
|
+
|
|
26
|
+
def initialize: (
|
|
27
|
+
from_color: yellow,
|
|
28
|
+
to_color: red,
|
|
29
|
+
policy: String,
|
|
30
|
+
failure: Failure?,
|
|
31
|
+
metrics: Metrics
|
|
32
|
+
) -> void
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
module Domain
|
|
3
|
+
module Telemetry
|
|
4
|
+
# Emitted for every recovery probe.
|
|
5
|
+
class RecoveryProbeCompleted < Data
|
|
6
|
+
attr_reader outcome: probe_outcome
|
|
7
|
+
# Latency of the recovering dependency.
|
|
8
|
+
attr_reader duration_ms: Float
|
|
9
|
+
attr_reader failure: Failure?
|
|
10
|
+
# Recovery metrics after this probe.
|
|
11
|
+
attr_reader progress: Metrics
|
|
12
|
+
|
|
13
|
+
def self.new: (
|
|
14
|
+
outcome: probe_outcome,
|
|
15
|
+
duration_ms: Float,
|
|
16
|
+
failure: Failure?,
|
|
17
|
+
progress: Metrics
|
|
18
|
+
) -> instance
|
|
19
|
+
|
|
20
|
+
def initialize: (
|
|
21
|
+
outcome: probe_outcome,
|
|
22
|
+
duration_ms: Float,
|
|
23
|
+
failure: Failure?,
|
|
24
|
+
progress: Metrics
|
|
25
|
+
) -> void
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
module Domain
|
|
3
|
+
module Telemetry
|
|
4
|
+
# state_transitioned variant: cool-off elapsed and the first probe explicitly entered recovery.
|
|
5
|
+
class RecoveryStarted < Data
|
|
6
|
+
include StateTransitioned
|
|
7
|
+
|
|
8
|
+
attr_reader from_color: red
|
|
9
|
+
attr_reader to_color: yellow
|
|
10
|
+
attr_reader breached_at: Time
|
|
11
|
+
|
|
12
|
+
def self.new: (
|
|
13
|
+
from_color: red,
|
|
14
|
+
to_color: yellow,
|
|
15
|
+
breached_at: Time
|
|
16
|
+
) -> instance
|
|
17
|
+
|
|
18
|
+
def initialize: (
|
|
19
|
+
from_color: red,
|
|
20
|
+
to_color: yellow,
|
|
21
|
+
breached_at: Time
|
|
22
|
+
) -> void
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
module Domain
|
|
3
|
+
module Telemetry
|
|
4
|
+
# state_transitioned variant: recovery policy resumed traffic.
|
|
5
|
+
class RecoverySucceeded < Data
|
|
6
|
+
include StateTransitioned
|
|
7
|
+
|
|
8
|
+
attr_reader from_color: yellow
|
|
9
|
+
attr_reader to_color: green
|
|
10
|
+
# Open set - the traffic-recovery policy self-identifies ("consecutive_successes", custom).
|
|
11
|
+
attr_reader policy: String
|
|
12
|
+
# Recovery metrics at the decision point.
|
|
13
|
+
attr_reader metrics: Metrics
|
|
14
|
+
|
|
15
|
+
def self.new: (
|
|
16
|
+
from_color: yellow,
|
|
17
|
+
to_color: green,
|
|
18
|
+
policy: String,
|
|
19
|
+
metrics: Metrics
|
|
20
|
+
) -> instance
|
|
21
|
+
|
|
22
|
+
def initialize: (
|
|
23
|
+
from_color: yellow,
|
|
24
|
+
to_color: green,
|
|
25
|
+
policy: String,
|
|
26
|
+
metrics: Metrics
|
|
27
|
+
) -> void
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
module Domain
|
|
3
|
+
module Telemetry
|
|
4
|
+
# Emitted for every Light#run.
|
|
5
|
+
class RunCompleted < Data
|
|
6
|
+
attr_reader outcome: run_outcome
|
|
7
|
+
attr_reader color: color
|
|
8
|
+
# nil when blocked (no user code ran)
|
|
9
|
+
# @note For performance reasons, durations might not be measured if nobody was subscribed at the start
|
|
10
|
+
# of the run - e.g. due to a race condition between active light and new subscription.
|
|
11
|
+
attr_reader duration_ms: Float?
|
|
12
|
+
# Present on failures and on successes caused by untracked (skipped) errors (see Failure#tracked).
|
|
13
|
+
attr_reader failure: Failure?
|
|
14
|
+
attr_reader fallback_used: bool
|
|
15
|
+
# Set only when blocked, nil under locked-red (no recovery scheduled).
|
|
16
|
+
attr_reader retry_after: Time?
|
|
17
|
+
|
|
18
|
+
def self.new: (
|
|
19
|
+
outcome: run_outcome,
|
|
20
|
+
color: color,
|
|
21
|
+
duration_ms: Float?,
|
|
22
|
+
failure: Failure?,
|
|
23
|
+
fallback_used: bool,
|
|
24
|
+
retry_after: Time?
|
|
25
|
+
) -> instance
|
|
26
|
+
|
|
27
|
+
def initialize: (
|
|
28
|
+
outcome: run_outcome,
|
|
29
|
+
color: color,
|
|
30
|
+
duration_ms: Float?,
|
|
31
|
+
failure: Failure?,
|
|
32
|
+
fallback_used: bool,
|
|
33
|
+
retry_after: Time?
|
|
34
|
+
) -> void
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
module Domain
|
|
3
|
+
module Telemetry
|
|
4
|
+
# Builds and emits RunCompleted events for one light color.
|
|
5
|
+
class RunRecorder
|
|
6
|
+
@emitter: Telemetry::Emitter
|
|
7
|
+
@color: color
|
|
8
|
+
|
|
9
|
+
def initialize: (emitter: Telemetry::Emitter, color: color) -> void
|
|
10
|
+
|
|
11
|
+
def subscribed?: () -> bool
|
|
12
|
+
|
|
13
|
+
def record_success: (duration_ms: duration_ms?, ?error: StandardError?) -> void
|
|
14
|
+
def record_failure: (StandardError, duration_ms: duration_ms?, fallback_used: bool) -> void
|
|
15
|
+
def record_blocked: (fallback_used: bool, retry_after: Time?) -> void
|
|
16
|
+
|
|
17
|
+
private def emit: (
|
|
18
|
+
outcome: run_outcome,
|
|
19
|
+
duration_ms: Float?,
|
|
20
|
+
failure: Failure?,
|
|
21
|
+
fallback_used: bool,
|
|
22
|
+
retry_after: Time?
|
|
23
|
+
) -> void
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
module Domain
|
|
3
|
+
module Telemetry
|
|
4
|
+
# The serializable subset of a light's configuration. No live objects (notifiers, data stores, procs) cross the
|
|
5
|
+
# telemetry boundary.
|
|
6
|
+
class Settings < Data
|
|
7
|
+
attr_reader cool_off_time: duration_seconds
|
|
8
|
+
attr_reader threshold: Float | Integer
|
|
9
|
+
attr_reader recovery_threshold: Integer
|
|
10
|
+
attr_reader window_size: duration_seconds?
|
|
11
|
+
# Constant names of the error matchers (matchers are named constants responding to #===).
|
|
12
|
+
attr_reader tracked_errors: Array[String]
|
|
13
|
+
attr_reader skipped_errors: Array[String]
|
|
14
|
+
attr_reader traffic_control: String
|
|
15
|
+
attr_reader traffic_control_params: Hash[String, untyped]
|
|
16
|
+
attr_reader traffic_recovery: String
|
|
17
|
+
attr_reader traffic_recovery_params: Hash[String, untyped]
|
|
18
|
+
|
|
19
|
+
def self.new: (
|
|
20
|
+
cool_off_time: duration_seconds,
|
|
21
|
+
threshold: Float | Integer,
|
|
22
|
+
recovery_threshold: Integer,
|
|
23
|
+
window_size: duration_seconds?,
|
|
24
|
+
tracked_errors: Array[String],
|
|
25
|
+
skipped_errors: Array[String],
|
|
26
|
+
traffic_control: String,
|
|
27
|
+
traffic_control_params: Hash[String, untyped],
|
|
28
|
+
traffic_recovery: String,
|
|
29
|
+
traffic_recovery_params: Hash[String, untyped]
|
|
30
|
+
) -> instance
|
|
31
|
+
|
|
32
|
+
def initialize: (
|
|
33
|
+
cool_off_time: duration_seconds,
|
|
34
|
+
threshold: Float | Integer,
|
|
35
|
+
recovery_threshold: Integer,
|
|
36
|
+
window_size: duration_seconds?,
|
|
37
|
+
tracked_errors: Array[String],
|
|
38
|
+
skipped_errors: Array[String],
|
|
39
|
+
traffic_control: String,
|
|
40
|
+
traffic_control_params: Hash[String, untyped],
|
|
41
|
+
traffic_recovery: String,
|
|
42
|
+
traffic_recovery_params: Hash[String, untyped]
|
|
43
|
+
) -> void
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
module Domain
|
|
3
|
+
module Telemetry
|
|
4
|
+
# Runtime name for the +state_transitioned+ union: a marker module included by every transition variant.
|
|
5
|
+
# Carries no behavior - it exists so subscription filters can dispatch on the union with
|
|
6
|
+
# Module#=== (RBS unions have no runtime constant). The type alias keeps typing the payload, this module names it at runtime.
|
|
7
|
+
module StateTransitioned
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
module Domain
|
|
3
|
+
module Telemetry
|
|
4
|
+
# state_transitioned variant: traffic control tripped the light.
|
|
5
|
+
class TrafficBreached < Data
|
|
6
|
+
include StateTransitioned
|
|
7
|
+
|
|
8
|
+
attr_reader from_color: green
|
|
9
|
+
attr_reader to_color: red
|
|
10
|
+
# Open set - the traffic-control policy self-identifies ("consecutive_errors", "error_rate", custom).
|
|
11
|
+
attr_reader policy: String
|
|
12
|
+
# Today's policies are consulted only when recording a failure, so a triggering exception is
|
|
13
|
+
# always present - but a future policy may breach without one (e.g. slow-call rate).
|
|
14
|
+
attr_reader failure: Failure?
|
|
15
|
+
# Request metrics at the decision point.
|
|
16
|
+
attr_reader metrics: Metrics
|
|
17
|
+
|
|
18
|
+
def self.new: (
|
|
19
|
+
from_color: green,
|
|
20
|
+
to_color: red,
|
|
21
|
+
policy: String,
|
|
22
|
+
failure: Failure?,
|
|
23
|
+
metrics: Metrics
|
|
24
|
+
) -> instance
|
|
25
|
+
|
|
26
|
+
def initialize: (
|
|
27
|
+
from_color: green,
|
|
28
|
+
to_color: red,
|
|
29
|
+
policy: String,
|
|
30
|
+
failure: Failure?,
|
|
31
|
+
metrics: Metrics
|
|
32
|
+
) -> void
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
module Domain
|
|
3
|
+
module Telemetry
|
|
4
|
+
type subscription_handler = ^(Envelope[event]) -> void
|
|
5
|
+
type subscription_filter = nil | singleton(RunCompleted) | singleton(TrafficBreached) | singleton(RecoveryStarted)
|
|
6
|
+
| singleton(RecoverySucceeded) | singleton(RecoveryFailed) | singleton(LockChanged)
|
|
7
|
+
| singleton(RecoveryProbeCompleted) | singleton(LightRegistered) | singleton(StateTransitioned)
|
|
8
|
+
|
|
9
|
+
# Run outcomes reflect the light's accounting, not the caller's experience: an untracked (skipped) error
|
|
10
|
+
# emits +:success+ with +failure.tracked = false+.
|
|
11
|
+
type run_outcome = :success | :failure | :blocked
|
|
12
|
+
type probe_outcome = :success | :failure
|
|
13
|
+
|
|
14
|
+
# Closed union over the state machine's edges. New traffic/recovery policies never add variants. They
|
|
15
|
+
# self-identify via the open +policy+ string inside the matching variant. Every variant includes
|
|
16
|
+
# the +StateTransitioned+ marker module - the union's runtime name.
|
|
17
|
+
type state_transitioned = TrafficBreached | RecoveryStarted | RecoverySucceeded | RecoveryFailed | LockChanged
|
|
18
|
+
|
|
19
|
+
type event = RunCompleted | state_transitioned | RecoveryProbeCompleted | LightRegistered
|
|
20
|
+
|
|
21
|
+
# The +event+ union at the class level - what emit and subscribed? take.
|
|
22
|
+
type event_class = singleton(RunCompleted)
|
|
23
|
+
| singleton(TrafficBreached)
|
|
24
|
+
| singleton(RecoveryStarted)
|
|
25
|
+
| singleton(RecoverySucceeded)
|
|
26
|
+
| singleton(RecoveryFailed)
|
|
27
|
+
| singleton(LockChanged)
|
|
28
|
+
| singleton(RecoveryProbeCompleted)
|
|
29
|
+
| singleton(LightRegistered)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
module Stoplight
|
|
2
2
|
module Domain
|
|
3
3
|
module Tracker
|
|
4
|
-
class RecoveryProbe
|
|
4
|
+
class RecoveryProbe
|
|
5
5
|
attr_reader traffic_recovery: _TrafficRecovery
|
|
6
|
-
attr_reader notifiers: Array[state_transition_notifier]
|
|
7
6
|
attr_reader config: Config
|
|
8
7
|
attr_reader metrics_store: _MetricsStore
|
|
9
8
|
attr_reader state_store: _StateStore
|
|
9
|
+
attr_reader emitter: Telemetry::Emitter
|
|
10
10
|
|
|
11
11
|
def initialize: (
|
|
12
12
|
config: Config,
|
|
13
13
|
traffic_recovery: _TrafficRecovery,
|
|
14
|
-
notifiers: Array[state_transition_notifier],
|
|
15
14
|
metrics_store: _MetricsStore,
|
|
16
15
|
state_store: _StateStore,
|
|
16
|
+
emitter: Telemetry::Emitter,
|
|
17
17
|
) -> void
|
|
18
18
|
|
|
19
|
-
def record_failure: (StandardError exception) -> void
|
|
20
|
-
def record_success: -> void
|
|
21
|
-
|
|
19
|
+
def record_failure: (StandardError exception, duration_ms: Float) -> void
|
|
20
|
+
def record_success: (duration_ms: Float) -> void
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
def recover: (duration_ms: Float, exception: StandardError?) -> void
|
|
25
|
+
def transition: (to_color: color) -> bool
|
|
22
26
|
end
|
|
23
27
|
end
|
|
24
28
|
end
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
module Stoplight
|
|
2
2
|
module Domain
|
|
3
3
|
module Tracker
|
|
4
|
-
class Request
|
|
4
|
+
class Request
|
|
5
5
|
attr_reader config: Config
|
|
6
6
|
attr_reader traffic_control: _TrafficControl
|
|
7
|
-
attr_reader notifiers: Array[state_transition_notifier]
|
|
8
7
|
attr_reader metrics_store: _MetricsStore
|
|
9
8
|
attr_reader state_store: _StateStore
|
|
9
|
+
attr_reader emitter: Telemetry::Emitter
|
|
10
10
|
|
|
11
11
|
def initialize: (
|
|
12
12
|
config: Config,
|
|
13
13
|
traffic_control: _TrafficControl,
|
|
14
|
-
notifiers: Array[state_transition_notifier],
|
|
15
14
|
metrics_store: _MetricsStore,
|
|
16
15
|
state_store: _StateStore,
|
|
16
|
+
emitter: Telemetry::Emitter,
|
|
17
17
|
) -> void
|
|
18
18
|
|
|
19
19
|
def record_failure: (StandardError exception) -> void
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
module Domain
|
|
3
|
+
type timestamp = Float | Integer
|
|
4
|
+
type duration_seconds = Integer
|
|
5
|
+
type duration_ms = Float
|
|
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
|
+
type recovery_decision = :green | :yellow | :red
|
|
20
|
+
type error_notifier = _ErrorNotifier
|
|
21
|
+
|
|
22
|
+
# Percentage as decimal (0.0 to 1.0)
|
|
23
|
+
type percentage = Float
|
|
24
|
+
end
|
|
25
|
+
end
|
data/sig/stoplight/error.rbs
CHANGED
|
@@ -3,13 +3,21 @@ module Stoplight
|
|
|
3
3
|
class Base < StandardError
|
|
4
4
|
end
|
|
5
5
|
|
|
6
|
+
class UnregisteredLightError < Base
|
|
7
|
+
end
|
|
8
|
+
|
|
6
9
|
class ConfigurationError < Base
|
|
7
10
|
end
|
|
8
11
|
|
|
9
12
|
class IncorrectColor < Base
|
|
10
13
|
end
|
|
11
14
|
|
|
15
|
+
class TooManySubscriptions < Base
|
|
16
|
+
end
|
|
17
|
+
|
|
12
18
|
class RedLight < Base
|
|
19
|
+
EXCEPTION_MESSAGE: String
|
|
20
|
+
|
|
13
21
|
attr_reader light_name: String
|
|
14
22
|
attr_reader cool_off_time: Numeric
|
|
15
23
|
attr_reader retry_after: Time?
|