hydrafetch 0.7.0 → 0.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/README.md +1 -1
- data/lib/hydrafetch/client.rb +3 -0
- data/lib/hydrafetch/errors.rb +1 -1
- data/lib/hydrafetch/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 965080a26c2ea8d7dff1ba22650813befcb8550e1ff34f24a35f797498414e3e
|
|
4
|
+
data.tar.gz: 953227cd85d06a7a7e57c7f36a7ed890648b7fe48478f60bff4ce07adac1fb2d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7847bb450f9dda5693519f82e3899326508d398c7ace1055a10671699013f7589b2944f2bad0abc374207a0fcfdbb87e2e341c5972dd7e947ef8ac3c657aea22
|
|
7
|
+
data.tar.gz: c9fddce74fb9b98987147d85cbac5a00650cbe2578348531f31025c016545cf75984c8cbc533c45a927096ef560f8371d6702f025880099fa1ccaca759e28c2d
|
data/README.md
CHANGED
|
@@ -205,7 +205,7 @@ end
|
|
|
205
205
|
| 429 | rate limited | yes, twice |
|
|
206
206
|
| 5xx | upstream failure | yes, twice |
|
|
207
207
|
|
|
208
|
-
Retries wait as long as the response asks through `Retry-After` or `retryAfterSeconds`, and otherwise back off with jitter. When the response asks for more than 30 seconds the client does not wait; it raises at once and `e.retry_after` gives the seconds to wait before asking again. A dropped connection is retried too, including while the client follows a job, and a job that fails is never started a second time.
|
|
208
|
+
Retries wait as long as the response asks through `Retry-After` or `retryAfterSeconds`, and otherwise back off with jitter. When the response asks for more than 30 seconds the client does not wait; it raises at once and `e.retry_after` gives the seconds to wait before asking again. A dropped connection is retried too, including while the client follows a job, and a job that fails is never started a second time. Every POST carries an Idempotency-Key that its own retries reuse, so a retry after a dropped connection returns the first answer instead of running and charging again.
|
|
209
209
|
|
|
210
210
|
A 503 from `scrape` means the origin is unreachable, usually a dead domain or a broken certificate.
|
|
211
211
|
|
data/lib/hydrafetch/client.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require "json"
|
|
2
|
+
require "securerandom"
|
|
2
3
|
require "net/http"
|
|
3
4
|
require "time"
|
|
4
5
|
require "uri"
|
|
@@ -185,10 +186,12 @@ module Hydrafetch
|
|
|
185
186
|
uri.query = URI.encode_www_form(query) unless query.nil? || query.empty?
|
|
186
187
|
|
|
187
188
|
attempt = 0
|
|
189
|
+
idempotency_key = verb == Net::HTTP::Post ? SecureRandom.uuid : nil
|
|
188
190
|
begin
|
|
189
191
|
req = verb.new(uri)
|
|
190
192
|
req["X-API-Key"] = @api_key
|
|
191
193
|
req["Accept"] = "application/json"
|
|
194
|
+
req["Idempotency-Key"] = idempotency_key if idempotency_key
|
|
192
195
|
if body
|
|
193
196
|
req["Content-Type"] = "application/json"
|
|
194
197
|
req.body = JSON.generate(body)
|
data/lib/hydrafetch/errors.rb
CHANGED
data/lib/hydrafetch/version.rb
CHANGED