Module: HTTPX::Plugins::Retries::OptionsMethods

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

Instance Method Summary collapse

Instance Method Details

#option_max_retries(value) ⇒ Object

Raises:

  • (TypeError)


59
60
61
62
63
64
# File 'lib/httpx/plugins/retries.rb', line 59

def option_max_retries(value)
  num = Integer(value)
  raise TypeError, ":max_retries must be positive" unless num.positive?

  num
end

#option_retry_after(value) ⇒ Object



42
43
44
45
46
47
48
49
50
# File 'lib/httpx/plugins/retries.rb', line 42

def option_retry_after(value)
  # return early if callable
  unless value.respond_to?(:call)
    value = Float(value)
    raise TypeError, ":retry_after must be positive" unless value.positive?
  end

  value
end

#option_retry_change_requests(v) ⇒ Object



66
67
68
# File 'lib/httpx/plugins/retries.rb', line 66

def option_retry_change_requests(v)
  v
end

#option_retry_jitter(value) ⇒ Object

Raises:

  • (TypeError)


52
53
54
55
56
57
# File 'lib/httpx/plugins/retries.rb', line 52

def option_retry_jitter(value)
  # return early if callable
  raise TypeError, ":retry_jitter must be callable" unless value.respond_to?(:call)

  value
end

#option_retry_on(value) ⇒ Object

Raises:

  • (TypeError)


70
71
72
73
74
# File 'lib/httpx/plugins/retries.rb', line 70

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

  value
end