Class: HTTPX::Timeout
- Inherits:
-
Object
- Object
- HTTPX::Timeout
- Defined in:
- lib/httpx/timeout.rb
Constant Summary collapse
- CONNECT_TIMEOUT =
60- OPERATION_TIMEOUT =
60- KEEP_ALIVE_TIMEOUT =
20
Instance Attribute Summary collapse
-
#connect_timeout ⇒ Object
readonly
Returns the value of attribute connect_timeout.
-
#keep_alive_timeout ⇒ Object
readonly
Returns the value of attribute keep_alive_timeout.
-
#operation_timeout ⇒ Object
readonly
Returns the value of attribute operation_timeout.
-
#total_timeout ⇒ Object
readonly
Returns the value of attribute total_timeout.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(connect_timeout: CONNECT_TIMEOUT, operation_timeout: OPERATION_TIMEOUT, keep_alive_timeout: KEEP_ALIVE_TIMEOUT, total_timeout: nil, loop_timeout: nil) ⇒ Timeout
constructor
A new instance of Timeout.
- #merge(other) ⇒ Object
Constructor Details
#initialize(connect_timeout: CONNECT_TIMEOUT, operation_timeout: OPERATION_TIMEOUT, keep_alive_timeout: KEEP_ALIVE_TIMEOUT, total_timeout: nil, loop_timeout: nil) ⇒ Timeout
Returns a new instance of Timeout.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/httpx/timeout.rb', line 19 def initialize(connect_timeout: CONNECT_TIMEOUT, operation_timeout: OPERATION_TIMEOUT, keep_alive_timeout: KEEP_ALIVE_TIMEOUT, total_timeout: nil, loop_timeout: nil) @connect_timeout = connect_timeout @operation_timeout = operation_timeout @keep_alive_timeout = keep_alive_timeout @total_timeout = total_timeout return unless loop_timeout # :nocov: warn ":loop_timeout is deprecated, use :operation_timeout instead" @operation_timeout = loop_timeout # :nocov: end |
Instance Attribute Details
#connect_timeout ⇒ Object (readonly)
Returns the value of attribute connect_timeout.
17 18 19 |
# File 'lib/httpx/timeout.rb', line 17 def connect_timeout @connect_timeout end |
#keep_alive_timeout ⇒ Object (readonly)
Returns the value of attribute keep_alive_timeout.
17 18 19 |
# File 'lib/httpx/timeout.rb', line 17 def keep_alive_timeout @keep_alive_timeout end |
#operation_timeout ⇒ Object (readonly)
Returns the value of attribute operation_timeout.
17 18 19 |
# File 'lib/httpx/timeout.rb', line 17 def operation_timeout @operation_timeout end |
#total_timeout ⇒ Object (readonly)
Returns the value of attribute total_timeout.
17 18 19 |
# File 'lib/httpx/timeout.rb', line 17 def total_timeout @total_timeout end |
Class Method Details
.new(opts = {}) ⇒ Object
11 12 13 14 15 |
# File 'lib/httpx/timeout.rb', line 11 def self.new(opts = {}) return opts if opts.is_a?(Timeout) super(**opts) end |
Instance Method Details
#==(other) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/httpx/timeout.rb', line 37 def ==(other) if other.is_a?(Timeout) @connect_timeout == other.instance_variable_get(:@connect_timeout) && @operation_timeout == other.instance_variable_get(:@operation_timeout) && @keep_alive_timeout == other.instance_variable_get(:@keep_alive_timeout) && @total_timeout == other.instance_variable_get(:@total_timeout) else super end end |
#merge(other) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/httpx/timeout.rb', line 48 def merge(other) case other when Hash timeout = Timeout.new(other) merge(timeout) when Timeout connect_timeout = other.instance_variable_get(:@connect_timeout) || @connect_timeout operation_timeout = other.instance_variable_get(:@operation_timeout) || @operation_timeout keep_alive_timeout = other.instance_variable_get(:@keep_alive_timeout) || @keep_alive_timeout total_timeout = other.instance_variable_get(:@total_timeout) || @total_timeout Timeout.new(connect_timeout: connect_timeout, operation_timeout: operation_timeout, keep_alive_timeout: keep_alive_timeout, total_timeout: total_timeout) else raise ArgumentError, "can't merge with #{other.class}" end end |