Sha256: a315fbc0bc7118c872559fd828feb7ca0a010c98085100e9250b746fe4bf5f4e

Contents?: true

Size: 1.73 KB

Versions: 8

Compression:

Stored size: 1.73 KB

Contents

module HTTPX
  module Plugins
    module CircuitBreaker

      class CircuitStore
        @circuits: Hash[String, Circuit]

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

        def try_respond: (Request request) -> response?

        private

        def get_circuit_for_uri: (generic_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

        @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

8 entries across 8 versions & 1 rubygems

Version Path
httpx-0.24.7 sig/plugins/circuit_breaker.rbs
httpx-0.24.6 sig/plugins/circuit_breaker.rbs
httpx-0.24.5 sig/plugins/circuit_breaker.rbs
httpx-0.24.4 sig/plugins/circuit_breaker.rbs
httpx-0.24.3 sig/plugins/circuit_breaker.rbs
httpx-0.24.2 sig/plugins/circuit_breaker.rbs
httpx-0.24.1 sig/plugins/circuit_breaker.rbs
httpx-0.24.0 sig/plugins/circuit_breaker.rbs