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)


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

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



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

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

  value
end

#option_retry_change_requests(v) ⇒ Object



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

def option_retry_change_requests(v)
  v
end

#option_retry_jitter(value) ⇒ Object

Raises:

  • (TypeError)


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

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



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

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

  value
end