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,14 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
class Admin < Sinatra::Base
|
|
3
|
+
COLORS: Array[Domain::color]
|
|
4
|
+
ASSETS_PATH: String
|
|
5
|
+
ASSET_DIGESTS: Hash[String, String]
|
|
6
|
+
ONE_YEAR_IN_SECONDS: Integer
|
|
7
|
+
include Helpers
|
|
8
|
+
|
|
9
|
+
self.@systems: Array[Wiring::System]
|
|
10
|
+
def self.add_system: (Wiring::System) -> void
|
|
11
|
+
def self.__stoplight__reset_systems!: -> void
|
|
12
|
+
def self.validate_persistent_system!: (Wiring::System) -> Wiring::System
|
|
13
|
+
end
|
|
14
|
+
end
|
data/sig/stoplight/color.rbs
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
module DataStore
|
|
3
|
+
# Configuration for Redis-backed Stoplight storage.
|
|
4
|
+
#
|
|
5
|
+
# @note This is a configuration object, not the storage implementation itself.
|
|
6
|
+
class Redis < Base
|
|
7
|
+
KEY_SPACE: Infrastructure::Redis::Key
|
|
8
|
+
|
|
9
|
+
attr_reader redis: Infrastructure::redis
|
|
10
|
+
|
|
11
|
+
def initialize: (Infrastructure::redis) -> void
|
|
12
|
+
|
|
13
|
+
def self.key_space: -> Infrastructure::Redis::Key
|
|
14
|
+
def key_space: -> Infrastructure::Redis::Key
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -1,64 +1,68 @@
|
|
|
1
1
|
module Stoplight
|
|
2
2
|
module Domain
|
|
3
3
|
class Config < Data
|
|
4
|
+
attr_reader id: String
|
|
4
5
|
attr_reader threshold: percentage | Integer
|
|
5
|
-
attr_reader window_size:
|
|
6
|
-
attr_reader tracked_errors: Array[
|
|
7
|
-
attr_reader skipped_errors: Array[
|
|
6
|
+
attr_reader window_size: duration_seconds?
|
|
7
|
+
attr_reader tracked_errors: Array[Module]
|
|
8
|
+
attr_reader skipped_errors: Array[Module]
|
|
8
9
|
attr_reader name: String
|
|
9
|
-
attr_reader cool_off_time:
|
|
10
|
+
attr_reader cool_off_time: duration_seconds
|
|
10
11
|
attr_reader recovery_threshold: Integer
|
|
11
12
|
attr_reader traffic_control: _TrafficControl
|
|
12
13
|
attr_reader traffic_recovery: _TrafficRecovery
|
|
13
14
|
attr_reader error_notifier: error_notifier
|
|
14
|
-
attr_reader notifiers: Array[
|
|
15
|
-
attr_reader data_store:
|
|
15
|
+
attr_reader notifiers: Array[_StateTransitionNotifier]
|
|
16
|
+
attr_reader data_store: _DataStore
|
|
16
17
|
|
|
17
18
|
def self.new: (
|
|
19
|
+
id: String,
|
|
18
20
|
name: String,
|
|
19
|
-
cool_off_time:
|
|
21
|
+
cool_off_time: duration_seconds,
|
|
20
22
|
threshold: percentage | Integer,
|
|
21
23
|
recovery_threshold: Integer,
|
|
22
|
-
window_size:
|
|
23
|
-
tracked_errors: Array[
|
|
24
|
-
skipped_errors: Array[
|
|
24
|
+
window_size: duration_seconds?,
|
|
25
|
+
tracked_errors: Array[Module],
|
|
26
|
+
skipped_errors: Array[Module],
|
|
25
27
|
traffic_control: _TrafficControl,
|
|
26
28
|
traffic_recovery: _TrafficRecovery,
|
|
27
29
|
error_notifier: error_notifier,
|
|
28
|
-
notifiers: Array[
|
|
29
|
-
data_store:
|
|
30
|
+
notifiers: Array[_StateTransitionNotifier],
|
|
31
|
+
data_store: _DataStore
|
|
30
32
|
) -> instance
|
|
31
33
|
|
|
32
34
|
def initialize: (
|
|
35
|
+
id: String,
|
|
33
36
|
name: String,
|
|
34
|
-
cool_off_time:
|
|
37
|
+
cool_off_time: duration_seconds,
|
|
35
38
|
threshold: percentage | Integer,
|
|
36
39
|
recovery_threshold: Integer,
|
|
37
|
-
window_size:
|
|
38
|
-
tracked_errors: Array[
|
|
39
|
-
skipped_errors: Array[
|
|
40
|
+
window_size: duration_seconds?,
|
|
41
|
+
tracked_errors: Array[Module],
|
|
42
|
+
skipped_errors: Array[Module],
|
|
40
43
|
traffic_control: _TrafficControl,
|
|
41
44
|
traffic_recovery: _TrafficRecovery,
|
|
42
45
|
error_notifier: error_notifier,
|
|
43
|
-
notifiers: Array[
|
|
44
|
-
data_store:
|
|
46
|
+
notifiers: Array[_StateTransitionNotifier],
|
|
47
|
+
data_store: _DataStore
|
|
45
48
|
) -> void
|
|
46
49
|
|
|
47
50
|
def cool_off_time_in_milliseconds: () -> Integer
|
|
48
51
|
|
|
49
52
|
def with: (
|
|
53
|
+
?id: optional[String],
|
|
50
54
|
?name: optional[String],
|
|
51
|
-
?cool_off_time: optional[
|
|
55
|
+
?cool_off_time: optional[duration_seconds],
|
|
52
56
|
?threshold: optional[percentage | Integer],
|
|
53
57
|
?recovery_threshold: optional[Integer],
|
|
54
|
-
?window_size: optional[
|
|
55
|
-
?tracked_errors: optional[Array[
|
|
56
|
-
?skipped_errors: optional[Array[
|
|
58
|
+
?window_size: optional[duration_seconds?],
|
|
59
|
+
?tracked_errors: optional[Array[Module]],
|
|
60
|
+
?skipped_errors: optional[Array[Module]],
|
|
57
61
|
?traffic_control: optional[_TrafficControl],
|
|
58
62
|
?traffic_recovery: optional[_TrafficRecovery],
|
|
59
63
|
?error_notifier: optional[error_notifier],
|
|
60
|
-
?notifiers: optional[Array[
|
|
61
|
-
?data_store: optional[
|
|
64
|
+
?notifiers: optional[Array[_StateTransitionNotifier]],
|
|
65
|
+
?data_store: optional[_DataStore],
|
|
62
66
|
) -> Config | () -> Config
|
|
63
67
|
end
|
|
64
68
|
end
|
|
@@ -5,6 +5,10 @@ module Stoplight
|
|
|
5
5
|
@skipped: Array[_ExceptionMatcher]
|
|
6
6
|
|
|
7
7
|
def initialize: (tracked: Array[_ExceptionMatcher], skipped: Array[_ExceptionMatcher]) -> void
|
|
8
|
+
def with: (
|
|
9
|
+
?tracked: optional[Array[_ExceptionMatcher] | _ExceptionMatcher],
|
|
10
|
+
?skipped: optional[Array[_ExceptionMatcher] | _ExceptionMatcher]
|
|
11
|
+
) -> ErrorTrackingPolicy
|
|
8
12
|
def track?: (StandardError) -> bool
|
|
9
13
|
|
|
10
14
|
def skipped?: (StandardError) -> bool
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
module Domain
|
|
3
|
+
class Light
|
|
4
|
+
attr_reader name: String
|
|
5
|
+
attr_reader green_run_strategy: Strategies::GreenRunStrategy
|
|
6
|
+
attr_reader yellow_run_strategy: Strategies::YellowRunStrategy
|
|
7
|
+
attr_reader red_run_strategy: Strategies::RedRunStrategy
|
|
8
|
+
attr_reader state_store: _StateStore
|
|
9
|
+
|
|
10
|
+
@name: String
|
|
11
|
+
@lock_control: LockControl
|
|
12
|
+
@error_tracking_policy: ErrorTrackingPolicy
|
|
13
|
+
|
|
14
|
+
def initialize: (
|
|
15
|
+
String name,
|
|
16
|
+
green_run_strategy: Strategies::GreenRunStrategy,
|
|
17
|
+
yellow_run_strategy: Strategies::YellowRunStrategy,
|
|
18
|
+
red_run_strategy: Strategies::RedRunStrategy,
|
|
19
|
+
state_store: _StateStore,
|
|
20
|
+
lock_control: LockControl,
|
|
21
|
+
error_tracking_policy: ErrorTrackingPolicy
|
|
22
|
+
) -> void
|
|
23
|
+
|
|
24
|
+
def state: -> Domain::state
|
|
25
|
+
def color: -> Domain::color
|
|
26
|
+
def run: [T] (
|
|
27
|
+
?(^(StandardError?) -> T)?,
|
|
28
|
+
?tracked_errors: optional[Array[Domain::_ExceptionMatcher] | Domain::_ExceptionMatcher],
|
|
29
|
+
?skipped_errors: optional[Array[Domain::_ExceptionMatcher] | Domain::_ExceptionMatcher]
|
|
30
|
+
) { () -> T } -> T
|
|
31
|
+
def lock: (Domain::color) -> Light
|
|
32
|
+
def unlock: -> Light
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
def state_strategy_factory: (color) -> _RunStrategy
|
|
36
|
+
def state_snapshot: -> StateSnapshot
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module Stoplight
|
|
2
2
|
module Domain
|
|
3
3
|
class LightInfo < Data
|
|
4
|
-
|
|
4
|
+
attr_reader name: String
|
|
5
5
|
|
|
6
6
|
def self.new: (
|
|
7
7
|
name: String,
|
|
@@ -10,10 +10,6 @@ module Stoplight
|
|
|
10
10
|
def initialize: (
|
|
11
11
|
name: String,
|
|
12
12
|
) -> void
|
|
13
|
-
|
|
14
|
-
def with: (
|
|
15
|
-
?name: String,
|
|
16
|
-
) -> LightInfo
|
|
17
13
|
end
|
|
18
14
|
end
|
|
19
15
|
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
module Domain
|
|
3
|
+
class LockControl
|
|
4
|
+
@state_store: _StateStore
|
|
5
|
+
@emitter: Telemetry::Emitter
|
|
6
|
+
|
|
7
|
+
def initialize: (
|
|
8
|
+
state_store: _StateStore,
|
|
9
|
+
emitter: Telemetry::Emitter
|
|
10
|
+
) -> void
|
|
11
|
+
|
|
12
|
+
def lock: (color) -> void
|
|
13
|
+
def unlock: -> void
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -11,6 +11,12 @@ module Stoplight
|
|
|
11
11
|
# Returns the current time.
|
|
12
12
|
def current_time: () -> Time
|
|
13
13
|
|
|
14
|
+
# Returns monotonic time in ms
|
|
15
|
+
def monotonic_millis: () -> Float
|
|
16
|
+
|
|
17
|
+
# Returns monotonic time in s
|
|
18
|
+
def monotonic_seconds: () -> Float
|
|
19
|
+
|
|
14
20
|
# Converts a Unix timestamp to a Time object.
|
|
15
21
|
def at: (timestamp) -> Time
|
|
16
22
|
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
module Domain
|
|
3
|
+
# Called when Stoplight internals fail (e.g. Redis unavailable, notifier I/O).
|
|
4
|
+
interface _ErrorNotifier
|
|
5
|
+
def call: (StandardError) -> void
|
|
6
|
+
|
|
7
|
+
# Object methods
|
|
8
|
+
def ==: (untyped) -> bool
|
|
9
|
+
def is_a?: (untyped) -> bool
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -19,8 +19,8 @@ module Stoplight
|
|
|
19
19
|
# Records a successful circuit breaker execution
|
|
20
20
|
def record_success: () -> void
|
|
21
21
|
|
|
22
|
-
# Records a failed circuit breaker execution
|
|
23
|
-
def record_failure: (StandardError error) ->
|
|
22
|
+
# Records a failed circuit breaker execution and returns the resulting snapshot
|
|
23
|
+
def record_failure: (StandardError error) -> Domain::MetricsSnapshot
|
|
24
24
|
|
|
25
25
|
# Clears all metrics for this circuit
|
|
26
26
|
def clear: () -> void
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
module Domain
|
|
3
|
+
# Holds the information about existing lights.
|
|
4
|
+
# Each system has its own registry so you can query lights belonging to it.
|
|
5
|
+
interface _Registry
|
|
6
|
+
def ids: -> Array[String]
|
|
7
|
+
def register: (Config) -> void
|
|
8
|
+
def unregister: (String id) -> void
|
|
9
|
+
def config_for: (String id) -> Hash[String, untyped]?
|
|
10
|
+
def all_configs: -> Array[Hash[String, untyped]]
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -7,7 +7,8 @@ module Stoplight
|
|
|
7
7
|
# @param fallback A fallback proc to execute in case of an error.
|
|
8
8
|
def execute: [T] (
|
|
9
9
|
(^(StandardError?) -> T)? fallback,
|
|
10
|
-
state_snapshot: StateSnapshot
|
|
10
|
+
state_snapshot: StateSnapshot,
|
|
11
|
+
error_tracking_policy: ErrorTrackingPolicy
|
|
11
12
|
) { () -> T } -> T
|
|
12
13
|
end
|
|
13
14
|
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
module Domain
|
|
3
|
+
interface _StateTransitionNotifier
|
|
4
|
+
# Sends a notification when a Stoplight changes state.
|
|
5
|
+
#
|
|
6
|
+
# @param light The Stoplight instance triggering the notification.
|
|
7
|
+
# @param from_color The previous state color of the Stoplight.
|
|
8
|
+
# @param to_color The new state color of the Stoplight.
|
|
9
|
+
# @param error The error (if any) that caused the state change.
|
|
10
|
+
def notify: (Domain::LightInfo, Domain::color from_color, Domain::color to_color, ?StandardError? error) -> void
|
|
11
|
+
|
|
12
|
+
# Object methods needed for comparison/inspection
|
|
13
|
+
def ==: (untyped) -> bool
|
|
14
|
+
|
|
15
|
+
def class: -> Class
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
module Domain
|
|
3
|
+
# Consumer-facing side of the telemetry bus: subscription only. The producer side is internal
|
|
4
|
+
# (see Domain::_TelemetryPublisher). This is what +_System#telemetry+ returns.
|
|
5
|
+
interface _Telemetry
|
|
6
|
+
# Supports the following variants:
|
|
7
|
+
# - Firehose (no filter): every event, including types added in future versions - filter by payload class
|
|
8
|
+
# (+case envelope.payload+ narrows the union).
|
|
9
|
+
# - Filtered by event class: only that event, with the envelope's payload pre-narrowed.
|
|
10
|
+
# - Filtered by +StateTransitioned+: the closed transition union - the complete color timeline.
|
|
11
|
+
#
|
|
12
|
+
# @raise [Stoplight::Error::TooManySubscriptions] if the bus's subscription cap is reached.
|
|
13
|
+
def subscribe: () { (Telemetry::Envelope[Telemetry::event]) -> void } -> Telemetry::Subscription
|
|
14
|
+
| (singleton(Telemetry::RunCompleted)) { (Telemetry::Envelope[Telemetry::RunCompleted]) -> void } -> Telemetry::Subscription
|
|
15
|
+
| (singleton(Telemetry::TrafficBreached)) { (Telemetry::Envelope[Telemetry::TrafficBreached]) -> void } -> Telemetry::Subscription
|
|
16
|
+
| (singleton(Telemetry::RecoveryStarted)) { (Telemetry::Envelope[Telemetry::RecoveryStarted]) -> void } -> Telemetry::Subscription
|
|
17
|
+
| (singleton(Telemetry::RecoverySucceeded)) { (Telemetry::Envelope[Telemetry::RecoverySucceeded]) -> void } -> Telemetry::Subscription
|
|
18
|
+
| (singleton(Telemetry::RecoveryFailed)) { (Telemetry::Envelope[Telemetry::RecoveryFailed]) -> void } -> Telemetry::Subscription
|
|
19
|
+
| (singleton(Telemetry::LockChanged)) { (Telemetry::Envelope[Telemetry::LockChanged]) -> void } -> Telemetry::Subscription
|
|
20
|
+
| (singleton(Telemetry::RecoveryProbeCompleted)) { (Telemetry::Envelope[Telemetry::RecoveryProbeCompleted]) -> void } -> Telemetry::Subscription
|
|
21
|
+
| (singleton(Telemetry::LightRegistered)) { (Telemetry::Envelope[Telemetry::LightRegistered]) -> void } -> Telemetry::Subscription
|
|
22
|
+
| (singleton(Telemetry::StateTransitioned)) { (Telemetry::Envelope[Telemetry::state_transitioned]) -> void } -> Telemetry::Subscription
|
|
23
|
+
|
|
24
|
+
# Idempotent: removing an already-removed or unknown token is a no-op.
|
|
25
|
+
def unsubscribe: (Telemetry::Subscription) -> void
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
module Domain
|
|
3
|
+
# Producer-facing side of the telemetry bus, injected into Telemetry::Emitter. End users never
|
|
4
|
+
# see it: they get the consumer side (_Telemetry) from +_System#telemetry+.
|
|
5
|
+
interface _TelemetryPublisher
|
|
6
|
+
# True when any subscriber (firehose, exact class, or via the StateTransitioned marker) would
|
|
7
|
+
# receive this event class. The Emitter guards on it before building anything.
|
|
8
|
+
def subscribed?: (Telemetry::event_class) -> bool
|
|
9
|
+
|
|
10
|
+
# Delivers to every interested subscriber, synchronously, in subscription order.
|
|
11
|
+
def publish: (Telemetry::Envelope[Telemetry::event]) -> void
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -22,6 +22,10 @@ module Stoplight
|
|
|
22
22
|
# error_rate = metrics.failures.fdiv(total)
|
|
23
23
|
# error_rate >= 0.5 # Stop traffic when error rate reaches 50%
|
|
24
24
|
# end
|
|
25
|
+
#
|
|
26
|
+
# def name
|
|
27
|
+
# "error_rate_custom"
|
|
28
|
+
# end
|
|
25
29
|
# end
|
|
26
30
|
#
|
|
27
31
|
interface _TrafficControl
|
|
@@ -33,6 +37,9 @@ module Stoplight
|
|
|
33
37
|
# @return +true+ if traffic should be stopped otherwise false
|
|
34
38
|
def stop_traffic?: (Config, Domain::MetricsSnapshot) -> bool
|
|
35
39
|
|
|
40
|
+
# Returns a string identifier for this policy (e.g. "consecutive_errors", "error_rate").
|
|
41
|
+
def name: () -> String
|
|
42
|
+
|
|
36
43
|
# Object methods
|
|
37
44
|
def ==: (untyped) -> bool
|
|
38
45
|
def is_a?: (untyped) -> bool
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
module Stoplight
|
|
2
2
|
module Domain
|
|
3
|
-
type decision = :green | :yellow | :red
|
|
4
|
-
|
|
5
3
|
# Strategies for determining how to recover traffic flow through the Stoplight.
|
|
6
4
|
# These strategies evaluate recovery metrics to decide which color the Stoplight should
|
|
7
5
|
# transition to during the recovery process.
|
|
@@ -37,11 +35,12 @@ module Stoplight
|
|
|
37
35
|
|
|
38
36
|
# Determines the appropriate recovery state based on the Stoplight's
|
|
39
37
|
# current metrics and recovery progress.
|
|
40
|
-
def determine_color: (Config, Domain::MetricsSnapshot) ->
|
|
38
|
+
def determine_color: (Config, Domain::MetricsSnapshot) -> recovery_decision
|
|
41
39
|
|
|
42
40
|
# Object methods
|
|
43
41
|
def ==: (untyped) -> bool
|
|
44
42
|
def is_a?: (untyped) -> bool
|
|
43
|
+
def name: -> String
|
|
45
44
|
end
|
|
46
45
|
end
|
|
47
46
|
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
module Domain
|
|
3
|
+
module Strategies
|
|
4
|
+
class GreenRunStrategy
|
|
5
|
+
include _RunStrategy
|
|
6
|
+
|
|
7
|
+
attr_reader request_tracker: Tracker::Request
|
|
8
|
+
@run_recorder: Telemetry::RunRecorder
|
|
9
|
+
@clock: _Clock
|
|
10
|
+
|
|
11
|
+
def initialize: (request_tracker: Tracker::Request,
|
|
12
|
+
run_recorder: Telemetry::RunRecorder, clock: _Clock) -> void
|
|
13
|
+
|
|
14
|
+
def capture_started_at: () -> Float?
|
|
15
|
+
def duration_since: (Float?) -> duration_ms?
|
|
16
|
+
|
|
17
|
+
def record_error: (StandardError, duration_ms: duration_ms?, fallback_used: bool) -> void
|
|
18
|
+
def record_success: (duration_ms: duration_ms?, ?error: StandardError?)-> void
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
module Domain
|
|
3
|
+
module Strategies
|
|
4
|
+
class RedRunStrategy
|
|
5
|
+
include _RunStrategy
|
|
6
|
+
|
|
7
|
+
@name: String
|
|
8
|
+
@cool_off_time: duration_seconds
|
|
9
|
+
@run_recorder: Telemetry::RunRecorder
|
|
10
|
+
|
|
11
|
+
def initialize: (
|
|
12
|
+
name: String,
|
|
13
|
+
cool_off_time: duration_seconds,
|
|
14
|
+
run_recorder: Telemetry::RunRecorder,
|
|
15
|
+
) -> void
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -7,34 +7,45 @@ module Stoplight
|
|
|
7
7
|
attr_reader state_store: Domain::_StateStore
|
|
8
8
|
attr_reader metrics_store: _MetricsStore
|
|
9
9
|
attr_reader recovery_lock_store: _RecoveryLockStore
|
|
10
|
-
attr_reader notifiers: Array[state_transition_notifier]
|
|
11
10
|
attr_reader request_tracker: Tracker::RecoveryProbe
|
|
12
|
-
attr_reader red_run_strategy: RedRunStrategy
|
|
13
11
|
|
|
14
12
|
@name: String
|
|
15
13
|
@config: Domain::Config
|
|
16
|
-
@
|
|
14
|
+
@clock: _Clock
|
|
15
|
+
@run_recorder: Telemetry::RunRecorder
|
|
16
|
+
@emitter: Telemetry::Emitter
|
|
17
17
|
|
|
18
18
|
def initialize: (
|
|
19
19
|
name: String,
|
|
20
|
-
error_tracking_policy: ErrorTrackingPolicy,
|
|
21
|
-
notifiers: Array[state_transition_notifier],
|
|
22
20
|
request_tracker: Tracker::RecoveryProbe,
|
|
23
|
-
|
|
24
|
-
state_store: Domain::_StateStore,
|
|
21
|
+
state_store: _StateStore,
|
|
25
22
|
metrics_store: _MetricsStore,
|
|
26
23
|
recovery_lock_store: _RecoveryLockStore,
|
|
27
|
-
config:
|
|
24
|
+
config: Config,
|
|
25
|
+
clock: _Clock,
|
|
26
|
+
run_recorder: Telemetry::RunRecorder,
|
|
27
|
+
emitter: Telemetry::Emitter
|
|
28
28
|
) -> void
|
|
29
29
|
|
|
30
30
|
def with_recovery_lock: [T] (
|
|
31
31
|
fallback: (^(StandardError?) -> T)?,
|
|
32
32
|
state_snapshot: StateSnapshot,
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
) { (duration_ms) -> T } -> T
|
|
34
|
+
|
|
35
|
+
def capture_started_at: () -> Float
|
|
36
|
+
def duration_since: (duration_ms) -> duration_ms
|
|
37
|
+
|
|
38
|
+
def record_recovery_probe_success: (
|
|
39
|
+
duration_ms: duration_ms,
|
|
40
|
+
?error: StandardError?
|
|
41
|
+
) -> void
|
|
42
|
+
|
|
43
|
+
def record_recovery_probe_failure: (
|
|
44
|
+
StandardError,
|
|
45
|
+
duration_ms: duration_ms,
|
|
46
|
+
fallback_used: bool,
|
|
47
|
+
) -> void
|
|
35
48
|
|
|
36
|
-
def record_recovery_probe_success: () -> void
|
|
37
|
-
def record_recovery_probe_failure: (StandardError) -> void
|
|
38
49
|
def enter_recovery: (StateSnapshot) -> void
|
|
39
50
|
end
|
|
40
51
|
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
module Stoplight
|
|
2
|
+
module Domain
|
|
3
|
+
module Telemetry
|
|
4
|
+
# In-process telemetry bus.
|
|
5
|
+
#
|
|
6
|
+
# Contract:
|
|
7
|
+
# - Events are process-local observations: they describe what this process observed or did, not the
|
|
8
|
+
# globally shared circuit state.
|
|
9
|
+
# - Every color change this process observes or effects emits exactly one +state_transitioned+ event. That
|
|
10
|
+
# stream alone reconstructs the color timeline (breaches, recovery, and locks included).
|
|
11
|
+
# - Events are traffic-driven - no traffic, no events.
|
|
12
|
+
# - Handlers run synchronously on the calling thread and are error-isolated:
|
|
13
|
+
# a raising handler is routed to the error notifier and never affects the run.
|
|
14
|
+
# - Emission allocates nothing when nothing is subscribed to that event class - a transitions-only
|
|
15
|
+
# subscriber keeps RunCompleted emission free.
|
|
16
|
+
# - Publish pays for interested handlers only: no filter matching happens at publish time
|
|
17
|
+
# (interest is resolved at subscribe time), and subscriptions to other event classes add
|
|
18
|
+
# nothing. The handlers themselves run inline, so their cost belongs to the subscriber.
|
|
19
|
+
# Subscribing mid-publish takes effect on the next publish.
|
|
20
|
+
class Bus
|
|
21
|
+
# The consumer side (subscribe/unsubscribe), what +_System#telemetry+ returns.
|
|
22
|
+
include _Telemetry
|
|
23
|
+
|
|
24
|
+
# The producer side (publish/subscribed?), what wiring injects into Emitter.
|
|
25
|
+
include _TelemetryPublisher
|
|
26
|
+
|
|
27
|
+
@error_notifier: error_notifier
|
|
28
|
+
@mutex: Mutex
|
|
29
|
+
@max_subscriptions: Integer
|
|
30
|
+
@subscriptions: Array[[Subscription, subscription_filter, subscription_handler]]
|
|
31
|
+
@dispatch: Hash[Class, Array[subscription_handler]]
|
|
32
|
+
|
|
33
|
+
# Default cap on live subscriptions.
|
|
34
|
+
MAX_SUBSCRIPTIONS: Integer
|
|
35
|
+
|
|
36
|
+
# @param error_notifier receives any StandardError a subscriber's handler raises.
|
|
37
|
+
# @param max_subscriptions caps the number of live subscriptions - #subscribe raises
|
|
38
|
+
# Stoplight::Error::TooManySubscriptions once reached.
|
|
39
|
+
def initialize: (error_notifier: error_notifier, ?max_subscriptions: Integer) -> void
|
|
40
|
+
|
|
41
|
+
# Value-level mirror of the +event+ union. A new event type is added here and to the union
|
|
42
|
+
# together (a spec pins them in sync).
|
|
43
|
+
EVENT_CLASSES: Array[event_class]
|
|
44
|
+
|
|
45
|
+
private def rebuild: -> void
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|