Class: Factorix::HTTP::RetryDecorator
- Inherits:
-
Object
- Object
- Factorix::HTTP::RetryDecorator
- Defined in:
- lib/factorix/http/retry_decorator.rb
Overview
Adds automatic retry with exponential backoff to HTTP client
Wraps any HTTP client and retries requests on network errors using the configured RetryStrategy.
Instance Method Summary collapse
-
#get(uri, headers: {}) {|Net::HTTPResponse| ... } ⇒ Response
Execute a GET request with retry.
-
#head(uri, headers: {}) ⇒ Response
Execute a HEAD request with retry.
-
#post(uri, body:, headers: {}, content_type: nil) ⇒ Response
Execute a POST request with retry.
-
#request(method, uri, headers: {}, body: nil) {|Net::HTTPResponse| ... } ⇒ Response
Execute an HTTP request with retry.
Instance Method Details
#get(uri, headers: {}) {|Net::HTTPResponse| ... } ⇒ Response
Execute a GET request with retry
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
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
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 |