Class: SimpleConnect::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_connect/request.rb

Overview

Transport layer. Holds the Headers + retry policy + timeout/logger, and exposes #get / #post which return an immutable Result. Retries are delegated to the injected Retryable; per-retry sleep / delay policy lives there (see SimpleConnect::Retryable).

Constant Summary collapse

IPV4 =

Force the connection onto a single IP family instead of the OS default dual-stack resolution. nil leaves resolution to the OS.

:ipv4
IPV6 =
:ipv6
IP_FAMILIES =
{ IPV4 => Socket::AF_INET, IPV6 => Socket::AF_INET6 }.freeze

Instance Method Summary collapse

Constructor Details

#initialize(headers:, timeout:, retryable:, logger: nil, debug: false, ip_version: nil) ⇒ Request

Returns a new instance of Request.



15
16
17
18
19
20
21
22
# File 'lib/simple_connect/request.rb', line 15

def initialize(headers:, timeout:, retryable:, logger: nil, debug: false, ip_version: nil)
  @headers    = headers
  @timeout    = timeout
  @logger     = logger
  @retryable  = retryable
  @debug      = debug
  @ip_version = ip_version
end

Instance Method Details

#get(uri, body: "") ⇒ Object



24
25
26
# File 'lib/simple_connect/request.rb', line 24

def get(uri, body: "")
  request_with_retry(http_method: :get, body: body, uri: uri)
end

#post(uri, body:) ⇒ Object



28
29
30
# File 'lib/simple_connect/request.rb', line 28

def post(uri, body:)
  request_with_retry(http_method: :post, body: body, uri: uri)
end