shopify_api_extensions 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/shopify_api_extensions/backoff.rb +28 -7
- data/lib/shopify_api_extensions/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c941b2d40cd938d27a81562e21d5e1cc24254939
|
4
|
+
data.tar.gz: ebb922c0292452b14f44f997b49df06b24a1ae36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44917662ae3ff68b7b25d3aa478099220a0125d784a13d239ddcebf9e36acead1915a1e507b4406a6e6b25a3d1378bb1d062f11c86e2b8b2201713ecfebec5f7
|
7
|
+
data.tar.gz: 69f0effd50de8174f283dc08ee0d16f991fb4ac3fae03ebe0dfaee1e6a992ea1574f71c713cc0992084d0c5cde4ffaab5299cb640a50b4892557ed6588e325e7
|
data/README.md
CHANGED
@@ -2,11 +2,13 @@ ShopifyAPI::Connection.class_eval do
|
|
2
2
|
alias_method :shopify_request, :request
|
3
3
|
|
4
4
|
def request(*args)
|
5
|
-
|
6
|
-
|
5
|
+
network_retry = 0
|
6
|
+
network_limit = 10
|
7
|
+
|
8
|
+
rate_limit_retry = 0
|
9
|
+
rate_limit_limit = 30
|
7
10
|
|
8
11
|
begin
|
9
|
-
count += 1
|
10
12
|
shopify_request(*args)
|
11
13
|
rescue Exception => e
|
12
14
|
exceptions_to_retry = [
|
@@ -16,18 +18,37 @@ ShopifyAPI::Connection.class_eval do
|
|
16
18
|
Errno::EHOSTUNREACH,
|
17
19
|
EOFError,
|
18
20
|
Zlib::BufError,
|
19
|
-
SocketError
|
21
|
+
SocketError,
|
22
|
+
ActiveResource::SSLError,
|
23
|
+
# NOTE represents only 500x errors
|
24
|
+
ActiveResource::ServerError
|
20
25
|
]
|
21
26
|
|
22
27
|
if !exceptions_to_retry.include?(e.class)
|
23
28
|
raise
|
24
29
|
end
|
25
30
|
|
26
|
-
|
27
|
-
|
31
|
+
if e.class == ActiveResource::ClientError && e.message =~ /429/ && e.message =~ /Too Many Requests/
|
32
|
+
if rate_limit_retry > 0 && rate_limit_retry % 10 == 0
|
33
|
+
puts "Shopify Rate Limit Error Encountered"
|
34
|
+
end
|
35
|
+
|
36
|
+
if rate_limit_retry >= rate_limit_limit
|
37
|
+
raise
|
38
|
+
else
|
39
|
+
rate_limit_retry += 1
|
40
|
+
sleep(rate_limit_retry)
|
41
|
+
retry
|
42
|
+
end
|
43
|
+
elsif e.class == ActiveResource::ClientError
|
44
|
+
raise
|
45
|
+
end
|
46
|
+
|
47
|
+
if network_retry >= network_limit
|
28
48
|
raise
|
29
49
|
else
|
30
|
-
|
50
|
+
network_retry += 1
|
51
|
+
sleep(network_retry)
|
31
52
|
retry
|
32
53
|
end
|
33
54
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shopify_api_extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Bianco
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shopify_api
|