Module: Stoplight::Domain::Light::ConfigurationBuilderInterface
- Included in:
- Stoplight::Domain::Light
- Defined in:
- lib/stoplight/domain/light/configuration_builder_interface.rb
Overview
Implements light configuration behavior steep:ignore:start
Instance Method Summary collapse
- #with_cool_off_time(cool_off_time) ⇒ Stoplight::Light deprecated Deprecated.
- #with_data_store(data_store) ⇒ Stoplight::Light deprecated Deprecated.
- #with_error_notifier(&error_notifier) ⇒ Stoplight::Light deprecated private Deprecated.
- #with_notifiers(notifiers) ⇒ Stoplight::Light deprecated Deprecated.
- #with_skipped_errors(*skipped_errors) ⇒ Stoplight::Light deprecated Deprecated.
- #with_threshold(threshold) ⇒ Stoplight::Light deprecated Deprecated.
- #with_tracked_errors(*tracked_errors) ⇒ Stoplight::Light deprecated Deprecated.
- #with_window_size(window_size) ⇒ Stoplight::Light deprecated Deprecated.
Instance Method Details
#with_cool_off_time(cool_off_time) ⇒ Stoplight::Light
Configures cool off time. Stoplight automatically tries to recover from the red state after the cool off time.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/stoplight/domain/light/configuration_builder_interface.rb', line 47 def with_cool_off_time(cool_off_time) deprecate(<<~MSG) Light#with_cool_off_time is deprecated and will be removed in v6.0.0. Circuit breakers should be configured once at creation, not cloned with modifications. Instead of: light = Stoplight('api-call') modified = light.with_cool_off_time(cool_off_time) Configure correctly from the start: Stoplight('api-call', cool_off_time:) MSG with_without_warning(cool_off_time:) end |
#with_data_store(data_store) ⇒ Stoplight::Light
Configures data store to be used with this circuit breaker
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/stoplight/domain/light/configuration_builder_interface.rb', line 20 def with_data_store(data_store) deprecate(<<~MSG) Light#with_data_store is deprecated and will be removed in v6.0.0. Circuit breakers should be configured once at creation, not cloned with modifications. Instead of: light = Stoplight('api-call') modified = light.with_data_store(data_stare) Configure correctly from the start: Stoplight('api-call', data_store:) MSG with_without_warning(data_store:) end |
#with_error_notifier(&error_notifier) ⇒ 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.
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/stoplight/domain/light/configuration_builder_interface.rb', line 153 def with_error_notifier(&error_notifier) deprecate(<<~MSG) Light#with_error_notifier is deprecated and will be removed in v6.0.0. Circuit breakers should be configured once at creation, not cloned with modifications. Instead of: light = Stoplight('api-call') modified = light.with_error_notifier { |error| warn error } Configure correctly from the start: Stoplight('api-call', error_notifier: ->(error) { warn error }) MSG with_without_warning(error_notifier: error_notifier) end |
#with_notifiers(notifiers) ⇒ Stoplight::Light
Configures custom notifier
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/stoplight/domain/light/configuration_builder_interface.rb', line 132 def with_notifiers(notifiers) deprecate(<<~MSG) Light#with_notifiers is deprecated and will be removed in v6.0.0. Circuit breakers should be configured once at creation, not cloned with modifications. Instead of: light = Stoplight('api-call') modified = light.with_notifiers(notifiers) Configure correctly from the start: Stoplight('api-call', notifiers:) MSG with_without_warning(notifiers:) end |
#with_skipped_errors(*skipped_errors) ⇒ Stoplight::Light
Configures a custom list of skipped errors that do not count toward the threshold. Typically, such errors does not represent a real failure and handled somewhere else in the code.
In the example above, the ActiveRecord::RecordNotFound doesn’t move the circuit breaker into the red state.
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/stoplight/domain/light/configuration_builder_interface.rb', line 216 def with_skipped_errors(*skipped_errors) deprecate(<<~MSG) Light#with_skipped_errors is deprecated and will be removed in v6.0.0. Circuit breakers should be configured once at creation, not cloned with modifications. Instead of: light = Stoplight('api-call') modified = light.with_skipped_errors(ActiveRecord::RecordNotFound) Configure correctly from the start: Stoplight('api-call', skipped_errors: [ActiveRecord::RecordNotFound]) MSG with_without_warning(skipped_errors:) end |
#with_threshold(threshold) ⇒ Stoplight::Light
Configures custom threshold. After this number of failures Stoplight switches to the red state:
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/stoplight/domain/light/configuration_builder_interface.rb', line 74 def with_threshold(threshold) deprecate(<<~MSG) Light#with_threshold is deprecated and will be removed in v6.0.0. Circuit breakers should be configured once at creation, not cloned with modifications. Instead of: light = Stoplight('api-call') modified = light.with_threshold(threshold) Configure correctly from the start: Stoplight('api-call', threshold:) MSG with_without_warning(threshold:) end |
#with_tracked_errors(*tracked_errors) ⇒ Stoplight::Light
Configures a custom list of tracked errors that counts toward the threshold.
In the example above, 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.
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/stoplight/domain/light/configuration_builder_interface.rb', line 184 def with_tracked_errors(*tracked_errors) deprecate(<<~MSG) Light#with_tracked_errors is deprecated and will be removed in v6.0.0. Circuit breakers should be configured once at creation, not cloned with modifications. Instead of: light = Stoplight('api-call') modified = light.with_tracked_errors(TimeoutError, NetworkError) Configure correctly from the start: Stoplight('api-call', tracked_errors: [TimeoutError, NetworkError]) MSG with_without_warning(tracked_errors:) end |
#with_window_size(window_size) ⇒ Stoplight::Light
Configures custom window size which Stoplight uses to count failures. For example,
The above example will turn to red light only when 5 errors happen within 60 seconds period.
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/stoplight/domain/light/configuration_builder_interface.rb', line 104 def with_window_size(window_size) deprecate(<<~MSG) Light#with_window_size is deprecated and will be removed in v6.0.0. Circuit breakers should be configured once at creation, not cloned with modifications. Instead of: light = Stoplight('api-call') modified = light.with_window_size(window_size) Configure correctly from the start: Stoplight('api-call', window_size:) MSG with_without_warning(window_size:) end |