Class: Stoplight::Wiring::LightFactory Private
- Inherits:
-
Object
- Object
- Stoplight::Wiring::LightFactory
- Includes:
- Domain::_LightFactory
- Defined in:
- lib/stoplight/wiring/light_factory.rb,
lib/stoplight/wiring/light_factory/traffic_control_dsl.rb,
lib/stoplight/wiring/light_factory/traffic_recovery_dsl.rb,
sig/_private/stoplight/wiring/light_factory.rbs,
sig/_private/stoplight/wiring/light_factory/traffic_control_dsl.rbs,
sig/_private/stoplight/wiring/light_factory/traffic_recovery_dsl.rbs
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Concrete factory for building +Stoplight::Light++ instances with full dependency wiring.
This factory implements the Stoplight::Domain::LightFactory protocol. It knows how to:
1. Parse and transform user-provided settings
2. Wire together all Light dependencies using a DI container
3. Validate configuration compatibility
4. Construct fully-functional Light instances
Direct Known Subclasses
System::LightFactory, System::LightFactory::InternalLightFactory
Constant Summary collapse
- TrafficControlDsl =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
->(value) { case value in _ if value.respond_to?(:stop_traffic?) # TODO: can be removed in 6.0 value in :consecutive_errors Domain::TrafficControl::ConsecutiveErrors.new in :error_rate Domain::TrafficControl::ErrorRate.new in {error_rate: error_rate_settings} Domain::TrafficControl::ErrorRate.new(**error_rate_settings) else raise Stoplight::Error::ConfigurationError, <<~ERROR unsupported traffic_control strategy provided (`#{value}`). Supported options: * :consecutive_errors * :error_rate ERROR end }
- TrafficRecoveryDsl =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
->(value) { case value in _ if value.respond_to?(:determine_color) # TODO: remove in 6.0 value in :consecutive_successes Domain::TrafficRecovery::ConsecutiveSuccesses.new else raise Error::ConfigurationError, <<~ERROR unsupported traffic_recovery strategy provided (`#{value}`). Supported options: * :consecutive_successes ERROR end }
Instance Attribute Summary collapse
- #config ⇒ Domain::Config readonly private
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?) private
-
#build ⇒ Stoplight::Light
private
Builds a fully-configured Light instance.
- #build_with(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) ⇒ Object private
- #eql ⇒ Boolean private
- #hash ⇒ Integer private
-
#initialize(config:) ⇒ LightFactory
constructor
private
A new instance of LightFactory.
- #light_builder(config:) ⇒ LightBuilder private
- #light_factory ⇒ Domain::_LightFactory private
- #with(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) ⇒ Object private
Constructor Details
#initialize(config:) ⇒ LightFactory
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of LightFactory.
18 19 20 |
# File 'lib/stoplight/wiring/light_factory.rb', line 18 def initialize(config:) @config = config end |
Instance Attribute Details
#config ⇒ Domain::Config (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
116 117 118 |
# File 'lib/stoplight/wiring/light_factory.rb', line 116 def config @config end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
74 75 76 |
# File 'lib/stoplight/wiring/light_factory.rb', line 74 def ==(other) other.is_a?(self.class) && other.config == config end |
#build ⇒ Stoplight::Light
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Builds a fully-configured Light instance.
The method resolves all dependencies from the container and constructs a Light that's
ready to use. The Light is injected with a reference to this factory, allowing the
Stoplight::Light#with method to work for reconfiguration.
70 71 72 |
# File 'lib/stoplight/wiring/light_factory.rb', line 70 def build light_builder(config:).build end |
#build_with(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) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/stoplight/wiring/light_factory.rb', line 80 def build_with( 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 ) with( name:, cool_off_time:, threshold:, recovery_threshold:, window_size:, tracked_errors:, skipped_errors:, data_store:, error_notifier:, notifiers:, traffic_control:, traffic_recovery: ).build end |
#eql ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
9 |
# File 'sig/_private/stoplight/wiring/light_factory.rbs', line 9
def eql: (untyped other) -> bool
|
#hash ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
110 111 112 |
# File 'lib/stoplight/wiring/light_factory.rb', line 110 def hash [self.class, config].hash end |
#light_builder(config:) ⇒ LightBuilder
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
120 121 122 |
# File 'lib/stoplight/wiring/light_factory.rb', line 120 def light_builder(config:) LightBuilder.new(config:, factory: light_factory) end |
#light_factory ⇒ Domain::_LightFactory
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
124 |
# File 'lib/stoplight/wiring/light_factory.rb', line 124 def light_factory = self |
#with(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) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/stoplight/wiring/light_factory.rb', line 22 def with( 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 ) self.class.new( config: ConfigurationDsl.new( name:, cool_off_time:, threshold:, recovery_threshold:, window_size:, tracked_errors:, skipped_errors:, traffic_control:, traffic_recovery:, error_notifier:, data_store:, notifiers: ).configure!(config) ) end |