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).

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Request.



9
10
11
12
13
14
# File 'lib/simple_connect/request.rb', line 9

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

Instance Method Details

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



16
17
18
# File 'lib/simple_connect/request.rb', line 16

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

#post(uri, body:) ⇒ Object



20
21
22
# File 'lib/simple_connect/request.rb', line 20

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