Sha256: 891b8c601ac96f22472dd3a677ebd654c6f871d6088dcacf663f2931ac6702e1

Contents?: true

Size: 1.26 KB

Versions: 3

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

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

3 entries across 3 versions & 1 rubygems

Version Path
freno-client-0.9.0 lib/freno/throttler/circuit_breaker.rb
freno-client-0.8.3 lib/freno/throttler/circuit_breaker.rb
freno-client-0.8.2 lib/freno/throttler/circuit_breaker.rb