Sha256: f2cab75457d86bedbac579dfcd78b02014241b18982ae675eac5e7ecca401a7d

Contents?: true

Size: 925 Bytes

Versions: 5

Compression:

Stored size: 925 Bytes

Contents

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sidekiq-circuit-breaker-0.1.4 lib/sidekiq/circuit_breaker/manager.rb
sidekiq-circuit-breaker-0.1.3 lib/sidekiq/circuit_breaker/manager.rb
sidekiq-circuit-breaker-0.1.2 lib/sidekiq/circuit_breaker/manager.rb
sidekiq-circuit-breaker-0.1.1 lib/sidekiq/circuit_breaker/manager.rb
sidekiq-circuit-breaker-0.1.0 lib/sidekiq/circuit_breaker/manager.rb