Sha256: 523c19fc3a8d92d236aaa878d97ace4724de6057af5a5caef014c536e8fb4aeb

Contents?: true

Size: 1.23 KB

Versions: 4

Compression:

Stored size: 1.23 KB

Contents

module Freno
  class Throttler

    # A CircuitBreaker is the entry point of the pattern with same name.
    # (see https://martinfowler.com/bliki/CircuitBreaker.html)
    #
    # Clients that use circuit breakers to add resiliency to their processes
    # send `failure` or `sucess` messages to the CircuitBreaker depending on the
    # results of the last requests made.
    #
    # With that information, the circuit breaker determines whether or not to
    # allow the next request (`allow_request?`). A circuit is said to be open
    # when the next request is not allowed; and it's said to be closed when the
    # next request is allowed.
    #
    module CircuitBreaker

      # The Noop circuit breaker is the `:circuit_breaker` used by default in
      # the Throttler
      #
      # It always allows requests, and does nothing when given `success` or
      # `failure` messages. For that reason it doesn't provide any resiliency
      # guarantee.
      #
      # See https://github.com/jnunemaker/resilient for a real ruby implementation
      # of the CircuitBreaker pattern.
      #
      class Noop
        def self.allow_request?
          true
        end

        def self.success; end

        def self.failure; end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
freno-client-0.8.1 lib/freno/throttler/circuit_breaker.rb
freno-client-0.8.0 lib/freno/throttler/circuit_breaker.rb
freno-client-0.7.0 lib/freno/throttler/circuit_breaker.rb
freno-client-0.6.0 lib/freno/throttler/circuit_breaker.rb