Module: HTTPX::Plugins::CircuitBreaker::OptionsMethods

Defined in:
lib/httpx/plugins/circuit_breaker.rb

Instance Method Summary collapse

Instance Method Details

#option_circuit_breaker_break_in(value) ⇒ Object

Raises:

  • (TypeError)


115
116
117
118
119
120
# File 'lib/httpx/plugins/circuit_breaker.rb', line 115

def option_circuit_breaker_break_in(value)
  timeout = Float(value)
  raise TypeError, ":circuit_breaker_break_in must be positive" unless timeout.positive?

  timeout
end

#option_circuit_breaker_break_on(value) ⇒ Object

Raises:

  • (TypeError)


129
130
131
132
133
# File 'lib/httpx/plugins/circuit_breaker.rb', line 129

def option_circuit_breaker_break_on(value)
  raise TypeError, ":circuit_breaker_break_on must be called with the response" unless value.respond_to?(:call)

  value
end

#option_circuit_breaker_half_open_drip_rate(value) ⇒ Object

Raises:

  • (TypeError)


122
123
124
125
126
127
# File 'lib/httpx/plugins/circuit_breaker.rb', line 122

def option_circuit_breaker_half_open_drip_rate(value)
  ratio = Float(value)
  raise TypeError, ":circuit_breaker_half_open_drip_rate must be a number between 0 and 1" unless (0..1).cover?(ratio)

  ratio
end

#option_circuit_breaker_max_attempts(value) ⇒ Object

Raises:

  • (TypeError)


101
102
103
104
105
106
# File 'lib/httpx/plugins/circuit_breaker.rb', line 101

def option_circuit_breaker_max_attempts(value)
  attempts = Integer(value)
  raise TypeError, ":circuit_breaker_max_attempts must be positive" unless attempts.positive?

  attempts
end

#option_circuit_breaker_reset_attempts_in(value) ⇒ Object

Raises:

  • (TypeError)


108
109
110
111
112
113
# File 'lib/httpx/plugins/circuit_breaker.rb', line 108

def option_circuit_breaker_reset_attempts_in(value)
  timeout = Float(value)
  raise TypeError, ":circuit_breaker_reset_attempts_in must be positive" unless timeout.positive?

  timeout
end