Class: Factorix::HTTP::RetryDecorator
- Inherits:
-
Object
- Object
- Factorix::HTTP::RetryDecorator
- Defined in:
- lib/factorix/http/retry_decorator.rb,
sig/factorix/http/retry_decorator.rbs
Overview
Decorator that adds retry functionality to an HTTP client
Automatically retries transient errors (timeouts, connection issues) using an exponential backoff strategy with randomization.
Instance Attribute Summary collapse
-
#client ⇒ Client
readonly
Returns the value of attribute client.
-
#logger ⇒ Dry::Logger::Dispatcher
readonly
Returns the value of attribute logger.
-
#retry_strategy ⇒ RetryStrategy
readonly
Returns the value of attribute retry_strategy.
Instance Method Summary collapse
-
#get(uri, headers: {}) {|Net::HTTPResponse| ... } ⇒ Response
Execute a GET request with retry logic.
-
#head(uri, headers: {}) ⇒ Response
Execute a HEAD request with retry.
-
#post(uri, body:, headers: {}, content_type: nil) ⇒ Response
Execute a POST request with retry logic.
-
#request(method, uri, headers: {}, body: nil) {|Net::HTTPResponse| ... } ⇒ Response
Execute an HTTP request with retry logic.
Instance Attribute Details
#client ⇒ Client (readonly)
Returns the value of attribute client.
12 13 14 |
# File 'sig/factorix/http/retry_decorator.rbs', line 12 def client @client end |
#logger ⇒ Dry::Logger::Dispatcher (readonly)
Returns the value of attribute logger.
14 15 16 |
# File 'sig/factorix/http/retry_decorator.rbs', line 14 def logger @logger end |
#retry_strategy ⇒ RetryStrategy (readonly)
Returns the value of attribute retry_strategy.
13 14 15 |
# File 'sig/factorix/http/retry_decorator.rbs', line 13 def retry_strategy @retry_strategy end |
Instance Method Details
#get(uri, headers: {}) {|Net::HTTPResponse| ... } ⇒ Response
Execute a GET request with retry logic
39 40 41 42 43 |
# File 'lib/factorix/http/retry_decorator.rb', line 39 def get(uri, headers: {}, &block) retry_strategy.with_retry do client.get(uri, headers:, &block) end end |
#head(uri, headers: {}) ⇒ Response
Execute a HEAD request with retry
63 64 65 66 67 |
# File 'lib/factorix/http/retry_decorator.rb', line 63 def head(uri, headers: {}) retry_strategy.with_retry do client.head(uri, headers:) end end |
#post(uri, body:, headers: {}, content_type: nil) ⇒ Response
Execute a POST request with retry logic
52 53 54 55 56 |
# File 'lib/factorix/http/retry_decorator.rb', line 52 def post(uri, body:, headers: {}, content_type: nil) retry_strategy.with_retry do client.post(uri, body:, headers:, content_type:) end end |
#request(method, uri, headers: {}, body: nil) {|Net::HTTPResponse| ... } ⇒ Response
Execute an HTTP request with retry logic
27 28 29 30 31 |
# File 'lib/factorix/http/retry_decorator.rb', line 27 def request(method, uri, headers: {}, body: nil, &block) retry_strategy.with_retry do client.request(method, uri, headers:, body:, &block) end end |