shopify_api_retry 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -7
- data/lib/shopify_api_retry.rb +6 -2
- data/shopify_api_retry.gemspec +8 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52d7c3cac56c5a6bc3146fe32d68853bd36411718a9a24a23eecb1be5055ef2e
|
4
|
+
data.tar.gz: f6164b541570442bd62781338ab391f17d9d6a79cfa3d182960efc3046041b0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4098e6e2399e42830d4cad365b047c4ad8a1d1a24027e1a800ad04b7d3aa78d3acd5e07c279cdfd802bec916542211c6ad0ca67b819187329639ec762403dcc7
|
7
|
+
data.tar.gz: 6dcff84ded14acbfd948fe239ddc0b1cc71d25963e064f4f01db030b3d1cc5a157e6b0216a248c4f384c7f19f73e965e5c9da428e6438a04d2ccd81110148660
|
data/README.md
CHANGED
@@ -28,20 +28,20 @@ By default requests are retried when a Shopify rate limit error (HTTP 429) is re
|
|
28
28
|
```rb
|
29
29
|
require "shopify_api_retry" # requires "shopify_api" for you
|
30
30
|
|
31
|
-
ShopifyAPIRetry.retry { customer.update_attribute(:tags, "foo") }
|
32
|
-
customer = ShopifyAPIRetry.retry { ShopifyAPI::Customer.find(id) }
|
31
|
+
ShopifyAPIRetry::REST.retry { customer.update_attribute(:tags, "foo") }
|
32
|
+
customer = ShopifyAPIRetry::REST.retry { ShopifyAPI::Customer.find(id) }
|
33
33
|
```
|
34
34
|
|
35
35
|
You can override this:
|
36
36
|
```rb
|
37
|
-
ShopifyAPIRetry.retry(:wait => 3, :tries => 5) { customer.update_attribute(:tags, "foo") }
|
37
|
+
ShopifyAPIRetry::REST.retry(:wait => 3, :tries => 5) { customer.update_attribute(:tags, "foo") }
|
38
38
|
```
|
39
39
|
This will try the request 5 times, waiting 3 seconds between each attempt. If a retry fails after the given number
|
40
40
|
of `:tries` the last error will be raised.
|
41
41
|
|
42
42
|
You can also retry requests when other errors occur:
|
43
43
|
```rb
|
44
|
-
ShopifyAPIRetry.retry "5XX" => { :wait => 10, :tries => 2 } do
|
44
|
+
ShopifyAPIRetry::REST.retry "5XX" => { :wait => 10, :tries => 2 } do
|
45
45
|
customer.update_attribute(:tags, "foo")
|
46
46
|
end
|
47
47
|
```
|
@@ -49,7 +49,7 @@ This still retries rate limit requests, but also all HTTP 5XX errors.
|
|
49
49
|
|
50
50
|
Classes can be specified too:
|
51
51
|
```rb
|
52
|
-
ShopifyAPIRetry.retry SocketError => { :wait => 1, :tries => 5 } do
|
52
|
+
ShopifyAPIRetry::REST.retry SocketError => { :wait => 1, :tries => 5 } do
|
53
53
|
customer.update_attribute(:tags, "foo")
|
54
54
|
end
|
55
55
|
```
|
@@ -106,13 +106,15 @@ response's cost data.
|
|
106
106
|
|
107
107
|
### Global Defaults
|
108
108
|
|
109
|
+
You can configure global defaults to be used by REST and GraphQL calls. For example:
|
110
|
+
|
109
111
|
```rb
|
110
112
|
ShopifyAPIRetry.configure do |config|
|
111
113
|
config.default_wait = 2.5
|
112
114
|
config.default_tries = 10
|
113
115
|
|
114
|
-
# Use
|
115
|
-
config.on ["5XX", Net::
|
116
|
+
# Use default_* for these
|
117
|
+
config.on ["5XX", Net::ReadTimeout]
|
116
118
|
|
117
119
|
config.on SocketError, :tries => 2, :wait => 1
|
118
120
|
end
|
data/lib/shopify_api_retry.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
# We don't use this. We require it as convenience for the caller in case they do.
|
4
|
+
begin
|
5
|
+
require "shopify_api"
|
6
|
+
rescue LoadError
|
7
|
+
end
|
4
8
|
|
5
9
|
module ShopifyAPIRetry
|
6
|
-
VERSION = "0.
|
10
|
+
VERSION = "0.2.0"
|
7
11
|
|
8
12
|
class Config # :nodoc:
|
9
13
|
attr_writer :default_wait
|
data/shopify_api_retry.gemspec
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "shopify_api_retry"
|
4
|
+
|
1
5
|
Gem::Specification.new do |spec|
|
2
6
|
spec.name = "shopify_api_retry"
|
3
|
-
spec.version =
|
7
|
+
spec.version = ShopifyAPIRetry::VERSION
|
4
8
|
spec.authors = ["Skye Shaw"]
|
5
9
|
spec.email = ["skye.shaw@gmail.com"]
|
6
10
|
|
@@ -18,7 +22,9 @@ Gem::Specification.new do |spec|
|
|
18
22
|
spec.require_paths = ["lib"]
|
19
23
|
|
20
24
|
spec.required_ruby_version = ">= 2.3"
|
21
|
-
|
25
|
+
|
26
|
+
# I don't think we _really_ need this just too lazy to remove now.
|
27
|
+
spec.add_development_dependency "shopify_api", ">= 4.0"
|
22
28
|
|
23
29
|
spec.add_development_dependency "minitest", "~> 5.0"
|
24
30
|
spec.add_development_dependency "bundler"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shopify_api_retry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Skye Shaw
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shopify_api
|
@@ -17,7 +17,7 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '4.0'
|
20
|
-
type: :
|
20
|
+
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|