require 'sidekiq/circuit_breaker/api' module Sidekiq module CircuitBreaker class Manager def initialize(scope, options) @scope = scope @options = options end def evaluate_failure count = register_failure open if count >= @options.failure_threshold end def open? circuit_opened?(@scope) end def closed? !open? end def failure_count failure_count_for_scope(@scope) end def open open_circuit(@scope, @options.max_open_time) end def time_to_open time_to_open_the_circuit(@scope) end def register_failure register_failure_for_scope(@scope) end def failure_count failure_count_for_scope(@scope) end def register_success register_success_for_scope(@scope) end private include Sidekiq::CircuitBreaker::API end end end