From 34c30e6b7899fac0ae9844de6e91df2c458abf84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=ABma=20Bolshakov?= Date: Wed, 27 May 2026 08:32:22 +0200 Subject: [PATCH 1/5] Remove data_store, error_notificer, and notifiers from Stoplight() --- .../support/configure_light_world.rb | 2 +- features/stoplight/support/stoplight_world.rb | 24 ++++++----- lib/stoplight.rb | 41 ++++--------------- sig/stoplight.rbs | 3 -- spec/properties/color_spec.rb | 10 ++++- spec/properties/notifications_spec.rb | 9 +++- .../stoplight/admin/lights_repository_spec.rb | 12 ++++-- 7 files changed, 45 insertions(+), 56 deletions(-) diff --git a/features/stoplight/support/configure_light_world.rb b/features/stoplight/support/configure_light_world.rb index 5ac0fe93..45741562 100644 --- a/features/stoplight/support/configure_light_world.rb +++ b/features/stoplight/support/configure_light_world.rb @@ -7,7 +7,7 @@ def configure_light(name, table = nil) factory_method = ENV.fetch("STOPLIGHT_LIGHT_CREATION", "Stoplight()") case factory_method when "Stoplight()" - Stoplight(name, notifiers:, data_store:, **collect_settings(table)) + Stoplight(name, **collect_settings(table)) when "System#light" system.light(name, **collect_settings(table)) else diff --git a/features/stoplight/support/stoplight_world.rb b/features/stoplight/support/stoplight_world.rb index 8a5ec664..f0ca7adb 100644 --- a/features/stoplight/support/stoplight_world.rb +++ b/features/stoplight/support/stoplight_world.rb @@ -66,19 +66,21 @@ def reset! @last_exception = nil @last_result = nil @last_fallback_received_argument = :nothing - @data_store = case ENV.fetch("STOPLIGHT_DATA_STORE", "Memory") - when "Memory" - Stoplight::DataStore::Memory.new - when "Redis" - redis = Redis.new(url: ENV.fetch("STOPLIGHT_REDIS_URL", "redis://127.0.0.1:6379/0")) + Stoplight.configure(trust_me_im_an_engineer: true) do |config| + config.data_store = case ENV.fetch("STOPLIGHT_DATA_STORE", "Memory") + when "Memory" + Stoplight::DataStore::Memory.new + when "Redis" + redis = Redis.new(url: ENV.fetch("STOPLIGHT_REDIS_URL", "redis://127.0.0.1:6379/0")) - DatabaseCleaner[:redis].db = redis - DatabaseCleaner.clean_with(:deletion) - Stoplight::DataStore::Redis.new(redis) - else - raise ArgumentError, "unexpected data store" + DatabaseCleaner[:redis].db = redis + DatabaseCleaner.clean_with(:deletion) + Stoplight::DataStore::Redis.new(redis) + else + raise ArgumentError, "unexpected data store" + end + config.notifiers = [TestNotifier.new(notifications)] end - @notifiers = [TestNotifier.new(notifications)] end def system = @system ||= Stoplight.__stoplight__system(SecureRandom.uuid, notifiers:, data_store:) diff --git a/lib/stoplight.rb b/lib/stoplight.rb index f0de7c15..dbeb6c2f 100644 --- a/lib/stoplight.rb +++ b/lib/stoplight.rb @@ -261,19 +261,15 @@ def __stoplight__default_configuration end end -# Creates a new Stoplight circuit brNeaker with the given name and settings. +# Creates a new Stoplight circuit breaker with the given name and settings. # # @param name [String] The name of the circuit breaker. -# @param settings [Hash] Optional settings to configure the circuit breaker. -# @option settings [Numeric] :cool_off_time The time to wait before resetting the circuit breaker. -# @option settings [Stoplight::DataStore::Base] :data_store The data store to use for storing state. -# @option settings [Array] :notifiers A list of notifiers to use. -# @option settings [Numeric] :threshold The failure threshold to trip the circuit breaker. -# @option settings [Numeric] :window_size The size of the rolling window for failure tracking. -# @option settings [Array] :tracked_errors A list of errors to track. -# @option settings [Array] :skipped_errors A list of errors to skip. -# @option settings [Symbol, {Symbol, Hash{Symbol, any}}] :traffic_control The -# traffic control strategy to use. +# @param cool_off_time The time to wait before resetting the circuit breaker. +# @param threshold The failure threshold to trip the circuit breaker. +# @param window_size The size of the rolling window for failure tracking. +# @param tracked_errors A list of errors to track. +# @param skipped_errors A list of errors to skip. +# @param traffic_control The traffic control strategy to use. # # @return [Stoplight::Light] A new circuit breaker instance. # @raise [ArgumentError] If an unknown option is provided in the settings. @@ -281,9 +277,6 @@ def __stoplight__default_configuration # @example configure circuit breaker behavior # light = Stoplight("Payment API", window_size: 300, threshold: 5, cool_off_time: 60) # -# @example configure data store -# light = Stoplight("Payment API", data_store: Stoplight::DataStore::Redis.new(redis_client)) -# # In the example below, the +TimeoutError+ and +NetworkError+ exceptions # will be counted towards the threshold for moving the circuit breaker into the red state. # If not configured, the default tracked error is +StandardError+. @@ -313,26 +306,9 @@ def Stoplight( window_size: Stoplight::T.undefined, tracked_errors: Stoplight::T.undefined, skipped_errors: Stoplight::T.undefined, - data_store: Stoplight::T.undefined, - error_notifier: Stoplight::T.undefined, - notifiers: Stoplight::T.undefined, traffic_control: Stoplight::T.undefined, traffic_recovery: Stoplight::T.undefined ) # rubocop:disable Naming/MethodName - Stoplight::Common::Deprecations.deprecate(<<~MSG) if error_notifier != Stoplight::T.undefined - Passing "error_notifier" to Stoplight('#{name}') is deprecated and will be removed in v6.0.0. - - IMPORTANT: The `error_notifier` is NOT called for exceptions in your protected code. - It only reports internal Stoplight failures (e.g., Redis connection errors). - - To fix: Move `error_notifier` to global configuration: - - Stoplight.configure do |config| - config.error_notifier = ->(error) { Logger.warn(error) } - end - - See: https://github.com/bolshakov/stoplight#error-notifiers - MSG Stoplight.light( name, cool_off_time:, @@ -341,9 +317,6 @@ def Stoplight( window_size:, tracked_errors:, skipped_errors:, - data_store:, - error_notifier:, - notifiers:, traffic_control:, traffic_recovery: ) diff --git a/sig/stoplight.rbs b/sig/stoplight.rbs index d892f9fe..bbd1c02f 100644 --- a/sig/stoplight.rbs +++ b/sig/stoplight.rbs @@ -56,9 +56,6 @@ module Kernel ?window_size: Stoplight::optional[Stoplight::duration?], ?tracked_errors: Stoplight::optional[Array[Stoplight::_ExceptionMatcher] | Stoplight::_ExceptionMatcher], ?skipped_errors: Stoplight::optional[Array[Stoplight::_ExceptionMatcher] | Stoplight::_ExceptionMatcher], - ?data_store: Stoplight::optional[Stoplight::data_store], - ?error_notifier: Stoplight::optional[Stoplight::error_notifier], - ?notifiers: Stoplight::optional[Array[Stoplight::state_transition_notifier]], ?traffic_control: Stoplight::optional[Stoplight::traffic_control], ?traffic_recovery: Stoplight::optional[Stoplight::traffic_recovery], ) -> Stoplight::_Light diff --git a/spec/properties/color_spec.rb b/spec/properties/color_spec.rb index 209e719b..b74e0dba 100644 --- a/spec/properties/color_spec.rb +++ b/spec/properties/color_spec.rb @@ -8,7 +8,7 @@ property_of { array(10) { choose(Stoplight::Color::GREEN, Stoplight::Color::RED, Stoplight::Color::YELLOW) } }.check do |color_sequence| - light = Stoplight(SecureRandom.uuid, data_store:) + light = Stoplight(SecureRandom.uuid) color_sequence.each do |color| light.__send__(:state_store).transition_to_color(color) @@ -52,7 +52,7 @@ property_of { array(20) { [choose(true, false), range(1, 10)] } }.check do |executions_sequence| - light = Stoplight(SecureRandom.uuid, data_store:, cool_off_time: 5, recovery_threshold: 2) + light = Stoplight(SecureRandom.uuid, cool_off_time: 5, recovery_threshold: 2) transitions = [] executions_sequence.each do |(should_fail, time_gap)| @@ -71,6 +71,12 @@ end end + before do + Stoplight.configure(trust_me_im_an_engineer: true) do |config| + config.data_store = data_store + end + end + context "with memory data store" do let(:data_store) { Stoplight::DataStore::Memory.new } diff --git a/spec/properties/notifications_spec.rb b/spec/properties/notifications_spec.rb index 02c0972d..3f509f8a 100644 --- a/spec/properties/notifications_spec.rb +++ b/spec/properties/notifications_spec.rb @@ -39,9 +39,7 @@ def notifications(name) }.check do |executions_sequence| light = Stoplight( SecureRandom.uuid, - data_store:, cool_off_time: 3, - notifiers: [notifier], recovery_threshold: 2 ) @@ -70,6 +68,13 @@ def notifications(name) end end + before do + Stoplight.configure(trust_me_im_an_engineer: true) do |config| + config.data_store = data_store + config.notifiers = [notifier] + end + end + context "with memory data store" do let(:data_store) { Stoplight::DataStore::Memory.new } diff --git a/spec/unit/stoplight/admin/lights_repository_spec.rb b/spec/unit/stoplight/admin/lights_repository_spec.rb index 082d6ccc..eee6838a 100644 --- a/spec/unit/stoplight/admin/lights_repository_spec.rb +++ b/spec/unit/stoplight/admin/lights_repository_spec.rb @@ -25,7 +25,13 @@ end let(:data_store_config) { Stoplight::DataStore::Redis.new(redis) } let(:name) { "lights-repository" } - let(:light) { Stoplight(name, data_store: data_store_config) } + let(:light) { Stoplight(name) } + + before do + Stoplight.configure(trust_me_im_an_engineer: true) do |config| + config.data_store = data_store_config + end + end describe "#all" do subject(:lights) { repository.all } @@ -63,8 +69,8 @@ describe "#with_color" do before do - Stoplight("red-light", data_store: data_store_config).lock("red") - Stoplight("green-light", data_store: data_store_config).lock("green") + Stoplight("red-light").lock("red") + Stoplight("green-light").lock("green") end it "returns light with requested color" do From 8073eca4edfd790d6e84ff23eb314dd00aab4ece Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=ABma=20Bolshakov?= Date: Wed, 27 May 2026 08:44:56 +0200 Subject: [PATCH 2/5] Remove data_store, error_notificer, and notifiers from Stoplight.light() --- lib/stoplight.rb | 6 ------ sig/stoplight.rbs | 3 --- 2 files changed, 9 deletions(-) diff --git a/lib/stoplight.rb b/lib/stoplight.rb index dbeb6c2f..c15ba167 100644 --- a/lib/stoplight.rb +++ b/lib/stoplight.rb @@ -108,9 +108,6 @@ def light( window_size: T.undefined, tracked_errors: T.undefined, skipped_errors: T.undefined, - data_store: T.undefined, - error_notifier: T.undefined, - notifiers: T.undefined, traffic_control: T.undefined, traffic_recovery: T.undefined ) @@ -122,9 +119,6 @@ def light( window_size:, tracked_errors:, skipped_errors:, - data_store:, - error_notifier:, - notifiers:, traffic_control:, traffic_recovery: ).build diff --git a/sig/stoplight.rbs b/sig/stoplight.rbs index bbd1c02f..e92a14ba 100644 --- a/sig/stoplight.rbs +++ b/sig/stoplight.rbs @@ -38,9 +38,6 @@ module Stoplight ?window_size: optional[duration?], ?tracked_errors: optional[Array[_ExceptionMatcher] | _ExceptionMatcher], ?skipped_errors: optional[Array[_ExceptionMatcher] | _ExceptionMatcher], - ?data_store: optional[data_store], - ?error_notifier: optional[error_notifier], - ?notifiers: optional[Array[state_transition_notifier]], ?traffic_control: optional[traffic_control], ?traffic_recovery: optional[traffic_recovery], ) -> _Light From 2c937a2fbd9aa0e8b826bc97b86c1c6f541bb0a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=ABma=20Bolshakov?= Date: Wed, 27 May 2026 21:36:27 +0200 Subject: [PATCH 3/5] Remove data_store, error_notificer, and notifiers from Stoplight.system_light() --- lib/stoplight.rb | 8 +------- lib/stoplight/infrastructure/notifier/fail_safe.rb | 5 +---- lib/stoplight/wiring/fail_safe_config.rb | 7 +++++++ sig/_private/stoplight.rbs | 3 --- sig/_private/stoplight/wiring/fail_safe_config.rbs | 7 +++++++ 5 files changed, 16 insertions(+), 14 deletions(-) create mode 100644 lib/stoplight/wiring/fail_safe_config.rb create mode 100644 sig/_private/stoplight/wiring/fail_safe_config.rbs diff --git a/lib/stoplight.rb b/lib/stoplight.rb index c15ba167..bb55ca99 100644 --- a/lib/stoplight.rb +++ b/lib/stoplight.rb @@ -74,13 +74,10 @@ def system_light( window_size: T.undefined, tracked_errors: T.undefined, skipped_errors: T.undefined, - data_store: T.undefined, - error_notifier: T.undefined, - notifiers: T.undefined, traffic_control: T.undefined, traffic_recovery: T.undefined ) - Wiring::LightFactory.new(config: Wiring::DefaultConfig).with( + Wiring::LightFactory.new(config: Wiring::FailSafeConfig).with( name: "__stoplight__#{name}", cool_off_time:, threshold:, @@ -88,9 +85,6 @@ def system_light( window_size:, tracked_errors:, skipped_errors:, - data_store:, - error_notifier:, - notifiers:, traffic_control:, traffic_recovery: ).build diff --git a/lib/stoplight/infrastructure/notifier/fail_safe.rb b/lib/stoplight/infrastructure/notifier/fail_safe.rb index f24cad6e..58531858 100644 --- a/lib/stoplight/infrastructure/notifier/fail_safe.rb +++ b/lib/stoplight/infrastructure/notifier/fail_safe.rb @@ -39,10 +39,7 @@ def ==(other) end private def circuit_breaker - @circuit_breaker ||= Stoplight.system_light( - "stoplight:notifier:fail_safe:#{notifier.class.name}", - notifiers: [] - ) + @circuit_breaker ||= Stoplight.system_light("stoplight:notifier:fail_safe:#{notifier.class.name}") end end end diff --git a/lib/stoplight/wiring/fail_safe_config.rb b/lib/stoplight/wiring/fail_safe_config.rb new file mode 100644 index 00000000..e448ceee --- /dev/null +++ b/lib/stoplight/wiring/fail_safe_config.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +module Stoplight + module Wiring + FailSafeConfig = DefaultConfig.with(notifiers: []) + end +end diff --git a/sig/_private/stoplight.rbs b/sig/_private/stoplight.rbs index 49cf3899..efff5962 100644 --- a/sig/_private/stoplight.rbs +++ b/sig/_private/stoplight.rbs @@ -19,9 +19,6 @@ module Stoplight ?window_size: optional[duration?], ?tracked_errors: optional[Array[_ExceptionMatcher]], ?skipped_errors: optional[Array[_ExceptionMatcher]], - ?data_store: optional[data_store], - ?error_notifier: optional[error_notifier], - ?notifiers: optional[Array[state_transition_notifier]], ?traffic_control: optional[traffic_control], ?traffic_recovery: optional[traffic_recovery], ) -> Domain::Light diff --git a/sig/_private/stoplight/wiring/fail_safe_config.rbs b/sig/_private/stoplight/wiring/fail_safe_config.rbs new file mode 100644 index 00000000..f4197312 --- /dev/null +++ b/sig/_private/stoplight/wiring/fail_safe_config.rbs @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +module Stoplight + module Wiring + FailSafeConfig: Domain::Config + end +end From 430c617536271d4f913718587089245a2810b4cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=ABma=20Bolshakov?= Date: Thu, 28 May 2026 08:38:48 +0200 Subject: [PATCH 4/5] Remove deprecated methods from factories --- README.md | 3 - UPGRADING.md | 6 +- bench/compare_redis.rb | 5 +- lib/stoplight.rb | 4 -- lib/stoplight/wiring/default_configuration.rb | 3 +- .../wiring/legacy_configuration_dsl.rb | 69 ------------------- lib/stoplight/wiring/light_factory.rb | 20 +++--- .../wiring/legacy_configuration_dsl.rbs | 37 ---------- spec/unit/stoplight_spec.rb | 13 +--- 9 files changed, 20 insertions(+), 140 deletions(-) delete mode 100644 lib/stoplight/wiring/legacy_configuration_dsl.rb delete mode 100644 sig/_private/stoplight/wiring/legacy_configuration_dsl.rbs diff --git a/README.md b/README.md index c942ae52..61b5f344 100644 --- a/README.md +++ b/README.md @@ -226,14 +226,11 @@ light = Stoplight("Payment Service") You can also provide settings during creation: ```ruby -data_store = Stoplight::DataStore::Redis.new(Redis.new) - light = Stoplight("Payment Service", window_size: 300, # Only count errors in the last five minutes threshold: 5, # 5 errors before turning red cool_off_time: 60, # Wait 60 seconds before attempting recovery recovery_threshold: 1, # 1 successful attempt to turn green again - data_store: data_store, # Use Redis for persistence tracked_errors: [TimeoutError], # Only count TimeoutError skipped_errors: [ValidationError] # Ignore ValidationError ) diff --git a/UPGRADING.md b/UPGRADING.md index 9064a8d1..70096630 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -1,6 +1,10 @@ ## Stoplight 6.0 - Removed Light#with() method -- Removed Ligh's `#with_data_store`, `#with_cool_off_time`, `#with_threshold`, `#with_window_size`, `#with_notifiers`, `#with_error_notifier`, `#with_tracked_errors`, `#with_skipped_errors` +- Removed Light's `#with_data_store`, `#with_cool_off_time`, `#with_threshold`, `#with_window_size`, `#with_notifiers`, + `#with_error_notifier`, `#with_tracked_errors`, `#with_skipped_errors` +- Remove `data_store`, `notifiers`, and `error_notifier` parameters from `Stoplight()` and `Stoplight.light()` methods. + From now on this could be configured only on the Stoplight/System level + ## Stoplight 5.0 Stoplight 5.0 introduces several breaking changes, so you'll need to set aside some time to update your code. The good diff --git a/bench/compare_redis.rb b/bench/compare_redis.rb index de48665e..cb4f4cfd 100644 --- a/bench/compare_redis.rb +++ b/bench/compare_redis.rb @@ -5,7 +5,10 @@ require "redis" redis = Redis.new -cashed_stoplight = Stoplight(SecureRandom.uuid, data_store: Stoplight::DataStore::Redis.new(redis), threshold: 10) +Stoplight.configure do |config| + config.data_store = Stoplight::DataStore::Redis.new(redis) +end +cashed_stoplight = Stoplight(SecureRandom.uuid, threshold: 10) Benchmark.ips do |b| b.report("after") { cashed_stoplight.run(->(_) {}) { raise if rand(11) % 10 == 1 } } diff --git a/lib/stoplight.rb b/lib/stoplight.rb index bb55ca99..b6d84408 100644 --- a/lib/stoplight.rb +++ b/lib/stoplight.rb @@ -123,10 +123,6 @@ def light( # Systems are composition roots that own infrastructure (data store, notifiers) # and enforce configuration consistency for all lights created within them. # - # @param name [String] Unique identifier for the system - # @param settings [Hash] Configuration options that override global defaults. - # @see Stoplight() documentation - # # @return [Stoplight::Wiring::System] A new system instance. # # @raise [ArgumentError] If a system with the given name already exists. diff --git a/lib/stoplight/wiring/default_configuration.rb b/lib/stoplight/wiring/default_configuration.rb index 7d56f7ea..72164db3 100644 --- a/lib/stoplight/wiring/default_configuration.rb +++ b/lib/stoplight/wiring/default_configuration.rb @@ -76,7 +76,8 @@ def notifiers = @config.notifiers # Builds and validates configuration def to_config! - LegacyConfigurationDsl.new( + SystemConfigurationDsl.new( + name: "default", cool_off_time: @cool_off_time, threshold: @threshold, recovery_threshold: @recovery_threshold, diff --git a/lib/stoplight/wiring/legacy_configuration_dsl.rb b/lib/stoplight/wiring/legacy_configuration_dsl.rb deleted file mode 100644 index e5572388..00000000 --- a/lib/stoplight/wiring/legacy_configuration_dsl.rb +++ /dev/null @@ -1,69 +0,0 @@ -# frozen_string_literal: true - -module Stoplight - module Wiring - class LegacyConfigurationDsl - def initialize( - name: T.undefined, - cool_off_time: T.undefined, - threshold: T.undefined, - recovery_threshold: T.undefined, - window_size: T.undefined, - tracked_errors: T.undefined, - skipped_errors: T.undefined, - data_store: T.undefined, - error_notifier: T.undefined, - notifiers: T.undefined, - traffic_control: T.undefined, - traffic_recovery: T.undefined - ) - @name = name - @cool_off_time = cool_off_time - @threshold = threshold - @recovery_threshold = recovery_threshold - @window_size = window_size - @tracked_errors = tracked_errors.is_a?(Undefined) ? tracked_errors : Array(tracked_errors) - @skipped_errors = skipped_errors.is_a?(Undefined) ? skipped_errors : Array(skipped_errors) - @traffic_control = traffic_control.is_a?(Undefined) ? traffic_control : LightFactory::TrafficControlDsl.call(traffic_control) - @traffic_recovery = traffic_recovery.is_a?(Undefined) ? traffic_recovery : LightFactory::TrafficRecoveryDsl.call(traffic_recovery) - @error_notifier = error_notifier - @data_store = data_store - @notifiers = notifiers - end - - def configure!(default_config) - ConfigCompatibilityValidator.call( - config: default_config.with( - name:, - cool_off_time:, - threshold:, - recovery_threshold:, - window_size:, - tracked_errors:, - skipped_errors:, - traffic_control:, - traffic_recovery:, - error_notifier:, - data_store:, - notifiers: - ) - ) - end - - private - - attr_reader :name - attr_reader :cool_off_time - attr_reader :threshold - attr_reader :recovery_threshold - attr_reader :window_size - attr_reader :error_notifier - attr_reader :data_store - attr_reader :notifiers - attr_reader :tracked_errors - attr_reader :skipped_errors - attr_reader :traffic_control - attr_reader :traffic_recovery - end - end -end diff --git a/lib/stoplight/wiring/light_factory.rb b/lib/stoplight/wiring/light_factory.rb index 420c4823..c256aa71 100644 --- a/lib/stoplight/wiring/light_factory.rb +++ b/lib/stoplight/wiring/light_factory.rb @@ -16,11 +16,13 @@ module Wiring # data store instance: # # data_store = Stoplight::DataStore::Memory.new - # light1 = Stoplight("foo", data_store: data_store) - # light2 = Stoplight("bar", data_store: data_store) + # system1 = Stoplight.system("API", data_store: data_store) + # light1 = system.light("foo") + # light2 = Stoplight("bar") # # light1 and light2 share the same underlying memory store # - # light3 = Stoplight("baz", data_store: Stoplight::DataStore::Memory.new) + # system2 = Stoplight.system("Payments", data_store: Stoplight::DataStore::Memory.new) + # light3 = system2.light("baz") # # light3 has its own independent store # # This singleton behavior is keyed by config object identity (object_id), @@ -64,21 +66,18 @@ def build end def with( - name: T.undefined, + name:, cool_off_time: T.undefined, threshold: T.undefined, recovery_threshold: T.undefined, window_size: T.undefined, tracked_errors: T.undefined, skipped_errors: T.undefined, - data_store: T.undefined, - error_notifier: T.undefined, - notifiers: T.undefined, traffic_control: T.undefined, traffic_recovery: T.undefined ) self.class.new( - config: LegacyConfigurationDsl.new( + config: LightConfigurationDsl.new( name:, cool_off_time:, threshold:, @@ -87,10 +86,7 @@ def with( tracked_errors:, skipped_errors:, traffic_control:, - traffic_recovery:, - error_notifier:, - data_store:, - notifiers: + traffic_recovery: ).configure!(config) ) end diff --git a/sig/_private/stoplight/wiring/legacy_configuration_dsl.rbs b/sig/_private/stoplight/wiring/legacy_configuration_dsl.rbs deleted file mode 100644 index 58f1d4c1..00000000 --- a/sig/_private/stoplight/wiring/legacy_configuration_dsl.rbs +++ /dev/null @@ -1,37 +0,0 @@ -module Stoplight - module Wiring - class LegacyConfigurationDsl - def initialize: ( - ?name: optional[String], - ?cool_off_time: optional[duration], - ?threshold: optional[percentage | Integer], - ?recovery_threshold: optional[Integer], - ?window_size: optional[duration?], - ?tracked_errors: optional[Array[_ExceptionMatcher] | _ExceptionMatcher], - ?skipped_errors: optional[Array[_ExceptionMatcher] | _ExceptionMatcher], - ?data_store: optional[data_store], - ?error_notifier: optional[error_notifier], - ?notifiers: optional[Array[state_transition_notifier]], - ?traffic_control: optional[traffic_control], - ?traffic_recovery: optional[traffic_recovery], - ) -> void - - def configure!: (Domain::Config default_config) -> Domain::Config - - private - - attr_reader name: optional[String] - attr_reader cool_off_time: optional[duration] - attr_reader threshold: optional[percentage | Integer] - attr_reader recovery_threshold: optional[Integer] - attr_reader window_size: optional[duration?] - attr_reader data_store: optional[data_store] - attr_reader error_notifier: optional[error_notifier] - attr_reader notifiers: optional[Array[state_transition_notifier]] - attr_reader tracked_errors: optional[Array[_ExceptionMatcher]] - attr_reader skipped_errors: optional[Array[_ExceptionMatcher]] - attr_reader traffic_control: optional[Domain::_TrafficControl] - attr_reader traffic_recovery: optional[Domain::_TrafficRecovery] - end - end -end diff --git a/spec/unit/stoplight_spec.rb b/spec/unit/stoplight_spec.rb index 154a2de3..f414eeb7 100644 --- a/spec/unit/stoplight_spec.rb +++ b/spec/unit/stoplight_spec.rb @@ -30,8 +30,7 @@ context "with settings" do subject(:light) { Stoplight(name, **settings) } - let(:settings) { {**config_settings, **dependencies_settings} } - let(:config_settings) do + let(:settings) do { cool_off_time: 1, threshold: 4, @@ -41,16 +40,6 @@ recovery_threshold: 3 } end - let(:dependencies_settings) do - { - data_store: data_store, - error_notifier: error_notifier, - notifiers: notifiers - } - end - let(:data_store) { Stoplight::DataStore::Memory.new } - let(:error_notifier) { ->(error) { warn error } } - let(:notifiers) { [Stoplight::Infrastructure::Notifier::IO.new($stdout)] } it "instantiates with the correct settings", pending: true do expect(light).to eq(Stoplight.__stoplight__default_light_factory.build_with(name:, **settings)) From 3b1a7eab2ce3ee7a4e46f5ca076e35b15cb5732b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=ABma=20Bolshakov?= Date: Thu, 28 May 2026 08:38:48 +0200 Subject: [PATCH 5/5] Remove deprecated methods from factories --- sig/_private/stoplight/wiring/light_factory.rbs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sig/_private/stoplight/wiring/light_factory.rbs b/sig/_private/stoplight/wiring/light_factory.rbs index 2f2d15bf..ec8098ae 100644 --- a/sig/_private/stoplight/wiring/light_factory.rbs +++ b/sig/_private/stoplight/wiring/light_factory.rbs @@ -63,16 +63,13 @@ module Stoplight # configuration from the current factory, with the provided # settings overriding specific values. def with: ( - ?name: optional[String], + name: String, ?cool_off_time: optional[duration], ?threshold: optional[percentage | Integer], ?recovery_threshold: optional[Integer], ?window_size: optional[duration?], ?tracked_errors: optional[Array[_ExceptionMatcher] | _ExceptionMatcher], ?skipped_errors: optional[Array[_ExceptionMatcher] | _ExceptionMatcher], - ?error_notifier: optional[error_notifier], - ?notifiers: optional[Array[state_transition_notifier]], - ?data_store: optional[data_store], ?traffic_control: optional[traffic_control], ?traffic_recovery: optional[traffic_recovery], ) -> LightFactory