Top Level Namespace
Defined Under Namespace
Modules: Stoplight
Instance Method Summary collapse
-
#Stoplight(name, cool_off_time: Stoplight::T.undefined, threshold: Stoplight::T.undefined, recovery_threshold: Stoplight::T.undefined, 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) ⇒ Stoplight::Light
Creates a new Stoplight circuit brNeaker with the given name and settings.
Instance Method Details
#Stoplight(name, cool_off_time: Stoplight::T.undefined, threshold: Stoplight::T.undefined, recovery_threshold: Stoplight::T.undefined, 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) ⇒ Stoplight::Light
Creates a new Stoplight circuit brNeaker with the given name and settings.
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.
In the example below , the ActiveRecord::RecordNotFound doesn’t move the circuit breaker into the red state.
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
# File 'lib/stoplight.rb', line 309 def Stoplight( name, cool_off_time: Stoplight::T.undefined, threshold: Stoplight::T.undefined, recovery_threshold: Stoplight::T.undefined, 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:, threshold:, recovery_threshold:, window_size:, tracked_errors:, skipped_errors:, data_store:, error_notifier:, notifiers:, traffic_control:, traffic_recovery: ) end |