chimera_http_client 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/action-ci.yml +58 -15
- data/.rubocop.yml +5 -0
- data/.ruby-version +1 -1
- data/README.markdown +67 -41
- data/TODO.markdown +7 -9
- data/chimera_http_client.gemspec +3 -3
- data/lib/chimera_http_client/base.rb +10 -6
- data/lib/chimera_http_client/queue.rb +1 -0
- data/lib/chimera_http_client/request.rb +49 -3
- data/lib/chimera_http_client/version.rb +1 -1
- data/lib/chimera_http_client.rb +2 -0
- metadata +8 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b13d3c092d285089ec23e09429db2129e3095c398ed1e829800bbcd0574e5c49
|
|
4
|
+
data.tar.gz: 8a646ce583338f381130879c86801349af06de6f2b32e19ab0a6a5d6677d8303
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b2813b2933fa8488973c345392fe879ac64b827180fa1d01dc872f83e13e23ebd4b9e95d9e3d7c17e457a9b73f293812d582a0fa9e22168a36abbb09439715cd
|
|
7
|
+
data.tar.gz: 5ec92f4d71bc1925f2e8b3db89b50ec237b554f7ff4d3ac65edc13dd6fd6200aa56ed1aba060e85afd325512eadfeb81fcdb83471995ca015010bbdcea8356b6
|
|
@@ -1,25 +1,68 @@
|
|
|
1
|
-
name:
|
|
1
|
+
name: Ruby CI
|
|
2
|
+
|
|
2
3
|
on:
|
|
3
|
-
pull_request:
|
|
4
4
|
push:
|
|
5
|
-
branches: [
|
|
5
|
+
branches: [ master ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ master ]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
concurrency:
|
|
11
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
12
|
+
cancel-in-progress: true
|
|
13
|
+
|
|
14
|
+
permissions:
|
|
15
|
+
contents: read
|
|
16
|
+
|
|
6
17
|
jobs:
|
|
7
18
|
test:
|
|
19
|
+
name: Test on ${{ matrix.os }} / ${{ matrix.ruby }}
|
|
8
20
|
strategy:
|
|
9
21
|
fail-fast: false
|
|
10
22
|
matrix:
|
|
11
|
-
os: [ubuntu-latest]
|
|
12
|
-
ruby: ['3.3', '3.4', '
|
|
13
|
-
|
|
23
|
+
os: [ubuntu-latest]
|
|
24
|
+
ruby: ['3.3', '3.4', '4.0']
|
|
25
|
+
experimental: [false]
|
|
26
|
+
# add certain optional combos whose failures won't block merges:
|
|
27
|
+
include:
|
|
28
|
+
- os: macos-latest
|
|
29
|
+
ruby: '4.0'
|
|
30
|
+
experimental: true
|
|
31
|
+
- os: ubuntu-latest
|
|
32
|
+
ruby: 'truffleruby'
|
|
33
|
+
experimental: true
|
|
34
|
+
- os: ubuntu-latest
|
|
35
|
+
ruby: 'jruby'
|
|
36
|
+
experimental: true
|
|
37
|
+
- os: windows-latest
|
|
38
|
+
ruby: '4.0'
|
|
39
|
+
experimental: true
|
|
14
40
|
|
|
15
|
-
runs-on: ${{ matrix.os }}
|
|
41
|
+
runs-on: ${{ matrix.os }}
|
|
16
42
|
|
|
17
43
|
steps:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
44
|
+
- uses: actions/checkout@v7
|
|
45
|
+
with:
|
|
46
|
+
fetch-depth: 0
|
|
47
|
+
|
|
48
|
+
- name: Set up Java for JRuby
|
|
49
|
+
if: ${{ matrix.ruby == 'jruby' }}
|
|
50
|
+
uses: actions/setup-java@v4
|
|
51
|
+
with:
|
|
52
|
+
distribution: temurin
|
|
53
|
+
java-version: '25'
|
|
54
|
+
|
|
55
|
+
- uses: ruby/setup-ruby@v1
|
|
56
|
+
with:
|
|
57
|
+
ruby-version: ${{ matrix.ruby }}
|
|
58
|
+
bundler-cache: true
|
|
59
|
+
|
|
60
|
+
- name: Print versions
|
|
61
|
+
run: |
|
|
62
|
+
ruby -v
|
|
63
|
+
gem -v
|
|
64
|
+
bundle -v
|
|
65
|
+
|
|
66
|
+
- name: Run linters and test suite
|
|
67
|
+
continue-on-error: ${{ matrix.experimental }}
|
|
68
|
+
run: bundle exec rake ci
|
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
4.0.6
|
data/README.markdown
CHANGED
|
@@ -17,18 +17,21 @@ The only other runtime dependency is Ruby's latest code loader [**zeitwerk**](ht
|
|
|
17
17
|
^
|
|
18
18
|
### Ruby version
|
|
19
19
|
|
|
20
|
-
| Chimera version | MRI Ruby version
|
|
21
|
-
|
|
22
|
-
| >= 1.
|
|
23
|
-
| >= 1.
|
|
24
|
-
| >= 1.
|
|
25
|
-
| >= 1.
|
|
26
|
-
|
|
|
27
|
-
|
|
|
20
|
+
| Chimera version | MRI Ruby version | JRuby | TruffleRuby |
|
|
21
|
+
|:----------------|:---------------------------------------------------------------------|:-----:|:-----------:|
|
|
22
|
+
| >= 1.8 | >= 3.3 (4.0 supported, older versions untested, likely still work) | yes | yes |
|
|
23
|
+
| >= 1.7 | >= 3.3 (older versions untested, likely still work) | yes | yes |
|
|
24
|
+
| >= 1.6 | >= 2.7 (all 3.x versions supported) | yes | yes |
|
|
25
|
+
| >= 1.4 | >= 2.5 (3.0 compatibility ensured) | yes | no |
|
|
26
|
+
| >= 1.1 | >= 2.5 | ? | ? |
|
|
27
|
+
| = 1.0 | >= 2.4, <= 3.0 | ? | ? |
|
|
28
|
+
| <= 0.5 | >= 2.1, <= 3.0 | ? | ? |
|
|
28
29
|
|
|
29
30
|
The test suite of v1.4 passes on **MRI Ruby** (2.5, 2.6, 2.7, 3.0) and on **JRuby**, but not on **TruffleRuby**.
|
|
30
31
|
The test suite of v1.6 passes on **MRI Ruby** (2.7, 3.0, 3.1, 3.2, 3.3) and on **JRuby** and **TruffleRuby**.
|
|
31
|
-
|
|
32
|
+
v1.8 is no longer tested against MRI Rubies older than 3.3 (but they are likely still supported).
|
|
33
|
+
All information above is given for **Linux**.
|
|
34
|
+
**MacOS & Windows** were only tested successfully against **MRI Ruby 4.0** (older versions likely work as well).
|
|
32
35
|
|
|
33
36
|
### ENV variables
|
|
34
37
|
|
|
@@ -38,36 +41,37 @@ Setting the environment variable `ENV['CHIMERA_HTTP_CLIENT_LOG_REQUESTS']` to `t
|
|
|
38
41
|
|
|
39
42
|
<!-- TOC depthFrom:1 depthTo:4 withLinks:1 updateOnSave:0 orderedList:0 -->
|
|
40
43
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
44
|
+
- [ChimeraHttpClient](#chimerahttpclient)
|
|
45
|
+
- [Dependencies](#dependencies)
|
|
46
|
+
- [Ruby version](#ruby-version)
|
|
47
|
+
- [ENV variables](#env-variables)
|
|
48
|
+
- [Table of Contents](#table-of-contents)
|
|
49
|
+
- [The Connection class](#the-connection-class)
|
|
50
|
+
- [Initialization](#initialization)
|
|
51
|
+
- [Mandatory initialization parameter `base_url`](#mandatory-initialization-parameter-base_url)
|
|
52
|
+
- [Optional initialization parameters](#optional-initialization-parameters)
|
|
53
|
+
- [Custom deserializers](#custom-deserializers)
|
|
54
|
+
- [Monitoring, metrics, instrumentation](#monitoring-metrics-instrumentation)
|
|
55
|
+
- [Request methods](#request-methods)
|
|
56
|
+
- [Mandatory request parameter `endpoint`](#mandatory-request-parameter-endpoint)
|
|
57
|
+
- [Optional request parameters](#optional-request-parameters)
|
|
58
|
+
- [Basic auth](#basic-auth)
|
|
59
|
+
- [Timeout duration](#timeout-duration)
|
|
60
|
+
- [Retrying requests](#retrying-requests)
|
|
61
|
+
- [Custom logger](#custom-logger)
|
|
62
|
+
- [Caching responses](#caching-responses)
|
|
63
|
+
- [Example usage](#example-usage)
|
|
64
|
+
- [The Request class](#the-request-class)
|
|
65
|
+
- [The Response class](#the-response-class)
|
|
66
|
+
- [Error classes](#error-classes)
|
|
67
|
+
- [The Queue class](#the-queue-class)
|
|
68
|
+
- [Queueing requests](#queueing-requests)
|
|
69
|
+
- [Executing requests in parallel](#executing-requests-in-parallel)
|
|
70
|
+
- [Empty the queue](#empty-the-queue)
|
|
71
|
+
- [Installation](#installation)
|
|
72
|
+
- [Maintainers and Contributors](#maintainers-and-contributors)
|
|
73
|
+
- [Roadmap](#roadmap)
|
|
74
|
+
- [Chimera](#chimera)
|
|
71
75
|
|
|
72
76
|
<!-- /TOC -->
|
|
73
77
|
|
|
@@ -98,6 +102,8 @@ The optional parameters are:
|
|
|
98
102
|
* `deserializers` - custom methods to deserialize the response body, below more details
|
|
99
103
|
* `logger` - an instance of a logger class that implements `#info`, `#warn` and `#error` methods
|
|
100
104
|
* `monitor` - to collect metrics about requests, the basis for your instrumentation needs
|
|
105
|
+
* `retries` - the number of times a failed idempotent request is retried, can be overwritten in any request, the default is `0` (no retries)
|
|
106
|
+
* `retry_delay` - the base delay in seconds between retries, can be overwritten in any request, the default is `1`
|
|
101
107
|
* `timeout` - the timeout for all requests, can be overwritten in any request, the default are 3 seconds
|
|
102
108
|
* `user_agent` - if you would like your calls to identify with a specific user agent
|
|
103
109
|
* `verbose` - the default is `false`, set it to true while debugging issues
|
|
@@ -171,6 +177,8 @@ All request methods expect a mandatory `endpoint` and an optional hash as parame
|
|
|
171
177
|
* `password` - used for a BasicAuth login
|
|
172
178
|
* `timeout` - set a custom timeout per request (the default is 3 seconds)
|
|
173
179
|
* `cache` - optionally overwrite the cache store set in `Connection` in any request
|
|
180
|
+
* `retries` - optionally overwrite the number of retries set in `Connection` for this request
|
|
181
|
+
* `retry_delay` - optionally overwrite the retry delay set in `Connection` for this request
|
|
174
182
|
* `monitoring_context` - pass additional information you want to collect with your instrumentation `monitor`
|
|
175
183
|
|
|
176
184
|
Example:
|
|
@@ -197,6 +205,24 @@ The default timeout duration is **3 seconds**.
|
|
|
197
205
|
|
|
198
206
|
If you want to use a different timeout, you can pass the key `timeout` when initializing the `Connection`. You can also overwrite it on every call.
|
|
199
207
|
|
|
208
|
+
#### Retrying requests
|
|
209
|
+
|
|
210
|
+
Pass `retries` (and optionally `retry_delay`) to `Connection.new`/`Queue.new`, or to any individual request, to automatically retry on transient failures:
|
|
211
|
+
|
|
212
|
+
```ruby
|
|
213
|
+
connection = ChimeraHttpClient::Connection.new(base_url: 'http://localhost:3000/v1', retries: 3, retry_delay: 1)
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
* `retries` - the maximum number of retry attempts. The default is `0` (no retries, fully opt-in).
|
|
217
|
+
* `retry_delay` - the base delay in seconds before the first retry. The default is `1`. Each subsequent retry doubles the previous delay (a fixed 2x backoff, not configurable): with `retry_delay: 1` the delays are `1s, 2s, 4s, ...`.
|
|
218
|
+
|
|
219
|
+
Retries are automatic and safe by design - they only apply to:
|
|
220
|
+
|
|
221
|
+
* **idempotent methods**: `get`, `put`, `delete`, `head` - never `post`/`patch`, regardless of the configured `retries`, since retrying a non-idempotent write could duplicate side effects.
|
|
222
|
+
* **transient errors**: `ConnectionError`, `TimeoutError`, `ServerError` (5xx) - never 4xx `ClientError`s, since retrying those can't change the outcome.
|
|
223
|
+
|
|
224
|
+
> Note for `Queue`: retries are implemented by re-queueing the failed request onto the same `Typhoeus::Hydra` that's already running the batch, so a retry can start as soon as its own request fails rather than waiting for the whole batch. One consequence: the `retry_delay` sleep happens inside that request's completion callback, which briefly pauses progress on *every other* in-flight request in the same queue (libcurl's multi interface is a single-threaded, cooperative event loop). This doesn't affect `Connection`, whose retries run sequentially with nothing else in flight.
|
|
225
|
+
|
|
200
226
|
#### Custom logger
|
|
201
227
|
|
|
202
228
|
By default no logging is happening. If you need request logging, you can pass your custom Logger to the key `logger` when initializing the `Connection`. It will write to `logger.info` when starting and when completing a request.
|
|
@@ -434,8 +460,8 @@ After checking out the repo, run `bundle install` and then `bundle execute rake`
|
|
|
434
460
|
|
|
435
461
|
> The test suite uses a Sinatra server to make real HTTP requests. It is mounted via Capybara_discoball and running in the same process. It is still running reasonably fast (on my MacBook Air):
|
|
436
462
|
|
|
437
|
-
Finished in
|
|
438
|
-
|
|
463
|
+
Finished in 1.02 seconds (files took 0.43805 seconds to load)
|
|
464
|
+
882 examples, 0 failures, 7 pending
|
|
439
465
|
|
|
440
466
|
You can also run `rake console` to open an irb session with the `ChimeraHttpClient` pre-loaded that will allow you to experiment.
|
|
441
467
|
|
data/TODO.markdown
CHANGED
|
@@ -105,15 +105,13 @@ _none known_
|
|
|
105
105
|
* [x] ~~hook up Travis-CI~~
|
|
106
106
|
* [x] ~~ensure it runs with Ruby 2.4 and newer~~
|
|
107
107
|
|
|
108
|
-
### Retry Requests
|
|
109
|
-
|
|
110
|
-
* [
|
|
111
|
-
* [
|
|
112
|
-
* [
|
|
113
|
-
* [
|
|
114
|
-
* [
|
|
115
|
-
* [ ] or document in README how to build a retry mechanism
|
|
116
|
-
* [ ] https://gist.github.com/kunalmodi/2939288
|
|
108
|
+
### ~~Retry Requests~~
|
|
109
|
+
|
|
110
|
+
* [x] ~~leverage Hydra to retry failed calls (Queue); Connection uses a sequential retry loop instead~~
|
|
111
|
+
* [x] ~~configure number of retries~~
|
|
112
|
+
* [x] ~~configure delay between retries~~
|
|
113
|
+
* [x] ~~retry idempotent calls GET, PUT, DELETE, HEAD automatically~~
|
|
114
|
+
* [x] ~~add example to README~~
|
|
117
115
|
|
|
118
116
|
### Queueing / run requests serialized
|
|
119
117
|
|
data/chimera_http_client.gemspec
CHANGED
|
@@ -40,9 +40,9 @@ Gem::Specification.new do |spec|
|
|
|
40
40
|
spec.add_development_dependency "irb", ">= 1.15"
|
|
41
41
|
spec.add_development_dependency "rake", ">= 13.2"
|
|
42
42
|
spec.add_development_dependency "rspec", "~> 3.13"
|
|
43
|
-
spec.add_development_dependency "rubocop", "~> 1.75
|
|
44
|
-
spec.add_development_dependency "rubocop-rake", "~> 0.7
|
|
45
|
-
spec.add_development_dependency "rubocop-rspec", "~> 3.
|
|
43
|
+
spec.add_development_dependency "rubocop", "~> 1.75"
|
|
44
|
+
spec.add_development_dependency "rubocop-rake", "~> 0.7"
|
|
45
|
+
spec.add_development_dependency "rubocop-rspec", "~> 3.10"
|
|
46
46
|
|
|
47
47
|
# only for server specs with real HTTP requests
|
|
48
48
|
spec.add_development_dependency "capybara", "~> 3.40"
|
|
@@ -10,11 +10,11 @@ module ChimeraHttpClient
|
|
|
10
10
|
@logger = options[:logger]
|
|
11
11
|
@monitor = options[:monitor]
|
|
12
12
|
@timeout = options[:timeout]
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
@cache = options[:cache]
|
|
14
|
+
@user_agent = options.fetch(:user_agent, USER_AGENT)
|
|
15
|
+
@verbose = options.fetch(:verbose, false)
|
|
16
|
+
@retries = options[:retries] || 0
|
|
17
|
+
@retry_delay = options[:retry_delay] || 1
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
private
|
|
@@ -22,6 +22,10 @@ module ChimeraHttpClient
|
|
|
22
22
|
# Add default values to call options
|
|
23
23
|
def augmented_options(options)
|
|
24
24
|
options[:timeout] ||= @timeout
|
|
25
|
+
options[:cache] = @cache if options[:cache].nil?
|
|
26
|
+
options[:verbose] = @verbose if options[:verbose].nil?
|
|
27
|
+
options[:retries] = @retries if options[:retries].nil?
|
|
28
|
+
options[:retry_delay] = @retry_delay if options[:retry_delay].nil?
|
|
25
29
|
|
|
26
30
|
options
|
|
27
31
|
end
|
|
@@ -41,7 +45,7 @@ module ChimeraHttpClient
|
|
|
41
45
|
end
|
|
42
46
|
|
|
43
47
|
def default_headers
|
|
44
|
-
{ "Content-Type" => "application/json" }
|
|
48
|
+
{ "Content-Type" => "application/json", "User-Agent" => @user_agent }
|
|
45
49
|
end
|
|
46
50
|
|
|
47
51
|
def default_deserializer
|
|
@@ -2,10 +2,20 @@ module ChimeraHttpClient
|
|
|
2
2
|
class Request
|
|
3
3
|
TIMEOUT_SECONDS = 3
|
|
4
4
|
|
|
5
|
+
# Only idempotent methods are retried automatically, regardless of the configured retries count
|
|
6
|
+
RETRYABLE_METHODS = %i(get put delete head).freeze
|
|
7
|
+
|
|
8
|
+
# Only network failures and 5xx are retried - 4xx client errors can't be fixed by retrying
|
|
9
|
+
RETRYABLE_ERRORS = [ConnectionError, TimeoutError, ServerError].freeze
|
|
10
|
+
|
|
11
|
+
RETRY_BACKOFF_MULTIPLIER = 2
|
|
12
|
+
|
|
5
13
|
attr_reader :request, :result
|
|
6
14
|
|
|
7
15
|
def initialize(options = {})
|
|
8
16
|
@options = options
|
|
17
|
+
@hydra = options[:hydra]
|
|
18
|
+
@attempt = 0
|
|
9
19
|
end
|
|
10
20
|
|
|
11
21
|
def run(url:, method:, body: nil, options: {}, headers: {})
|
|
@@ -13,6 +23,15 @@ module ChimeraHttpClient
|
|
|
13
23
|
|
|
14
24
|
@request.run
|
|
15
25
|
|
|
26
|
+
attempt = 0
|
|
27
|
+
while retryable?(method, @result, options, attempt)
|
|
28
|
+
attempt += 1
|
|
29
|
+
sleep(delay_for(attempt, options))
|
|
30
|
+
|
|
31
|
+
create(url: url, method: method, body: body, options: options, headers: headers)
|
|
32
|
+
@request.run
|
|
33
|
+
end
|
|
34
|
+
|
|
16
35
|
@result
|
|
17
36
|
end
|
|
18
37
|
|
|
@@ -25,6 +44,7 @@ module ChimeraHttpClient
|
|
|
25
44
|
timeout: options[:timeout] || TIMEOUT_SECONDS,
|
|
26
45
|
accept_encoding: "gzip",
|
|
27
46
|
cache: options[:cache],
|
|
47
|
+
verbose: options[:verbose],
|
|
28
48
|
}
|
|
29
49
|
|
|
30
50
|
# Basic-auth support:
|
|
@@ -52,11 +72,25 @@ module ChimeraHttpClient
|
|
|
52
72
|
url: url,
|
|
53
73
|
code: response.code,
|
|
54
74
|
runtime: runtime,
|
|
55
|
-
user_agent:
|
|
75
|
+
user_agent: headers["User-Agent"],
|
|
56
76
|
}
|
|
57
77
|
)
|
|
58
78
|
|
|
59
|
-
|
|
79
|
+
result = on_complete_handler(response)
|
|
80
|
+
|
|
81
|
+
# Used for queued requests (Queue): retries are re-queued onto the same Hydra from
|
|
82
|
+
# inside this callback, per Typhoeus::Hydra::Queueable#queue ("can even be done while
|
|
83
|
+
# the hydra is running"). Connection-built requests never have a @hydra, so this branch
|
|
84
|
+
# never triggers for them - their retries are handled by the loop in #run instead.
|
|
85
|
+
if @hydra && retryable?(method, result, options, @attempt)
|
|
86
|
+
@attempt += 1
|
|
87
|
+
sleep(delay_for(@attempt, options))
|
|
88
|
+
|
|
89
|
+
create(url: url, method: method, body: body, options: options, headers: headers)
|
|
90
|
+
@hydra.queue(@request)
|
|
91
|
+
else
|
|
92
|
+
@result = result
|
|
93
|
+
end
|
|
60
94
|
end
|
|
61
95
|
|
|
62
96
|
@options[:logger]&.info(
|
|
@@ -66,7 +100,7 @@ module ChimeraHttpClient
|
|
|
66
100
|
url: url,
|
|
67
101
|
code: nil,
|
|
68
102
|
runtime: 0,
|
|
69
|
-
user_agent:
|
|
103
|
+
user_agent: headers["User-Agent"],
|
|
70
104
|
}
|
|
71
105
|
)
|
|
72
106
|
|
|
@@ -75,6 +109,18 @@ module ChimeraHttpClient
|
|
|
75
109
|
|
|
76
110
|
private
|
|
77
111
|
|
|
112
|
+
def retryable?(method, result, options, attempt)
|
|
113
|
+
result.error? &&
|
|
114
|
+
RETRYABLE_METHODS.include?(method) &&
|
|
115
|
+
RETRYABLE_ERRORS.any? { |klass| result.is_a?(klass) } &&
|
|
116
|
+
attempt < options[:retries].to_i
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# Delay before retry attempt n (1-indexed): retry_delay * RETRY_BACKOFF_MULTIPLIER**(n - 1)
|
|
120
|
+
def delay_for(attempt, options)
|
|
121
|
+
options[:retry_delay].to_f * (RETRY_BACKOFF_MULTIPLIER**(attempt - 1))
|
|
122
|
+
end
|
|
123
|
+
|
|
78
124
|
def on_complete_handler(response)
|
|
79
125
|
return Response.new(response, @options) if response.success?
|
|
80
126
|
|
data/lib/chimera_http_client.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: chimera_http_client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andreas Finger
|
|
@@ -127,42 +127,42 @@ dependencies:
|
|
|
127
127
|
requirements:
|
|
128
128
|
- - "~>"
|
|
129
129
|
- !ruby/object:Gem::Version
|
|
130
|
-
version: 1.75
|
|
130
|
+
version: '1.75'
|
|
131
131
|
type: :development
|
|
132
132
|
prerelease: false
|
|
133
133
|
version_requirements: !ruby/object:Gem::Requirement
|
|
134
134
|
requirements:
|
|
135
135
|
- - "~>"
|
|
136
136
|
- !ruby/object:Gem::Version
|
|
137
|
-
version: 1.75
|
|
137
|
+
version: '1.75'
|
|
138
138
|
- !ruby/object:Gem::Dependency
|
|
139
139
|
name: rubocop-rake
|
|
140
140
|
requirement: !ruby/object:Gem::Requirement
|
|
141
141
|
requirements:
|
|
142
142
|
- - "~>"
|
|
143
143
|
- !ruby/object:Gem::Version
|
|
144
|
-
version: 0.7
|
|
144
|
+
version: '0.7'
|
|
145
145
|
type: :development
|
|
146
146
|
prerelease: false
|
|
147
147
|
version_requirements: !ruby/object:Gem::Requirement
|
|
148
148
|
requirements:
|
|
149
149
|
- - "~>"
|
|
150
150
|
- !ruby/object:Gem::Version
|
|
151
|
-
version: 0.7
|
|
151
|
+
version: '0.7'
|
|
152
152
|
- !ruby/object:Gem::Dependency
|
|
153
153
|
name: rubocop-rspec
|
|
154
154
|
requirement: !ruby/object:Gem::Requirement
|
|
155
155
|
requirements:
|
|
156
156
|
- - "~>"
|
|
157
157
|
- !ruby/object:Gem::Version
|
|
158
|
-
version: 3.
|
|
158
|
+
version: '3.10'
|
|
159
159
|
type: :development
|
|
160
160
|
prerelease: false
|
|
161
161
|
version_requirements: !ruby/object:Gem::Requirement
|
|
162
162
|
requirements:
|
|
163
163
|
- - "~>"
|
|
164
164
|
- !ruby/object:Gem::Version
|
|
165
|
-
version: 3.
|
|
165
|
+
version: '3.10'
|
|
166
166
|
- !ruby/object:Gem::Dependency
|
|
167
167
|
name: capybara
|
|
168
168
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -312,7 +312,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
312
312
|
- !ruby/object:Gem::Version
|
|
313
313
|
version: '0'
|
|
314
314
|
requirements: []
|
|
315
|
-
rubygems_version:
|
|
315
|
+
rubygems_version: 4.0.16
|
|
316
316
|
specification_version: 4
|
|
317
317
|
summary: General http client functionality to quickly connect to JSON REST API endpoints
|
|
318
318
|
and any others
|