Sha256: db2e1e4fac46aac1e3ddda044e2e4f1367a0b0c071cf0d49c0f9b4c438760a7c

Contents?: true

Size: 1.86 KB

Versions: 14

Compression:

Stored size: 1.86 KB

Contents

module HTTPX
  module Plugins
    module CircuitBreaker

      class CircuitStore
        @circuits: Hash[String, Circuit]

        @circuits_mutex: Thread::Mutex

        def try_open: (uri uri, response response) -> response?

        def try_respond: (Request request) -> response?

        def try_close: (http_uri uri) -> void

        private

        def get_circuit_for_uri: (uri uri) -> Circuit

        def initialize: (Options & _CircuitOptions options) -> void
      end

      class Circuit
        @state: :closed | :open | :half_open
        @max_attempts: Integer
        @reset_attempts_in: Float
        @break_in: Float
        @circuit_breaker_half_open_drip_rate: Float
        @attempts: Integer
        @real_attempts: Integer
        @drip_factor: Integer

        @response: response?
        @opened_at: Float?
        @attempted_at: Float?

        def respond: () -> response?

        def try_open: (response) -> response?

        def try_close: () -> void

        private

        def initialize: (Integer max_attempts, Float reset_attempts_in, Float break_in, Float circuit_breaker_half_open_drip_rate) -> void
      end

      interface _CircuitOptions
        def circuit_breaker_max_attempts: () -> Integer
        def circuit_breaker_reset_attempts_in: () -> Float
        def circuit_breaker_break_in: () -> Float
        def circuit_breaker_half_open_drip_rate: () -> Float
        def circuit_breaker_break_on: () -> (^(Response) -> boolish | nil)
      end

      def self.load_dependencies: (singleton(Session)) -> void
      def self.extra_options: (Options) -> (Options & _CircuitOptions)

      module InstanceMethods
        @circuit_store: CircuitStore

        private

        def try_circuit_open: (Request request, response response) -> response?
      end

    end

    type sessionCircuitBreaker = Session & CircuitBreaker::InstanceMethods
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
httpx-1.3.4 sig/plugins/circuit_breaker.rbs
httpx-1.3.3 sig/plugins/circuit_breaker.rbs
httpx-1.3.2 sig/plugins/circuit_breaker.rbs
httpx-1.3.1 sig/plugins/circuit_breaker.rbs
httpx-1.3.0 sig/plugins/circuit_breaker.rbs
httpx-1.2.6 sig/plugins/circuit_breaker.rbs
httpx-1.2.4 sig/plugins/circuit_breaker.rbs
httpx-1.2.3 sig/plugins/circuit_breaker.rbs
httpx-1.2.2 sig/plugins/circuit_breaker.rbs
httpx-1.2.1 sig/plugins/circuit_breaker.rbs
httpx-1.2.0 sig/plugins/circuit_breaker.rbs
httpx-1.1.5 sig/plugins/circuit_breaker.rbs
httpx-1.1.4 sig/plugins/circuit_breaker.rbs
httpx-1.1.3 sig/plugins/circuit_breaker.rbs