shopify_unlimited 0.0.14.threadsafe → 0.0.15.threadsafe
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/shopify_unlimited/shopify_api/throttle.rb +11 -4
- data/lib/shopify_unlimited/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Njc4NjgzNmIxMjBiMDk3MjI2NWJkYmY2ZjZkN2FiYzY2NWQ0ZDMwZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODllNjY5ZTFhNTJmZmU1NWU2NWMxZDQ2MzFmZTkzMTk2YWZkMTllMQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MDEyOWEwODYzOTkzNDNmYjg4YTM1OTQ1ZjhhZDY0MjEzMTIxYWQ1MzIyNWQw
|
10
|
+
MmM1M2Y3MDE5MjFhYmZhOTg2ZTBiOTZlZTY2Y2EzMjcxYzc4YzkyOGQ5YWU3
|
11
|
+
OTQ0YzAyMDBhZDAzNzliZWIxNjM4YjA3NmU4N2NlNGI2NjZkN2Q=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YzgzZTU1NWE0ODMxNDcwY2YxYzA2OWVkMjNkZGQ0OGViZWQ2ODgwYWFlOWQ5
|
14
|
+
YTRkZDI2MTY1MjI0ZWI4M2RiYzgyMjhhYmI0OTdmYTIxMjJmNmY1N2JkYmJl
|
15
|
+
ZTVjM2NjYWZmYjRjZDFmYmJhMmQyN2RkYzhiODIyYWFlYTdjNjk=
|
@@ -4,6 +4,12 @@
|
|
4
4
|
# of requests until finished, which will typically happen with
|
5
5
|
# any naive, non-stochastic implementation.
|
6
6
|
|
7
|
+
# currently this is only true when only one request at a time
|
8
|
+
# is passed to throttle.run
|
9
|
+
# When it becomes useful, we could add an argument to throttle.run
|
10
|
+
# to specify the number of expected requests. However, that would have
|
11
|
+
# has the downside that the thread might end up waiting a long time
|
12
|
+
# for a large enough block of requests.
|
7
13
|
|
8
14
|
module ShopifyAPI
|
9
15
|
class Shop
|
@@ -23,6 +29,7 @@ module ShopifyAPI
|
|
23
29
|
def run(&block)
|
24
30
|
value = nil
|
25
31
|
retries ||= 0
|
32
|
+
orig_logger = ActiveResource::Base.logger
|
26
33
|
begin
|
27
34
|
left = ShopifyAPI.credit_left
|
28
35
|
over = @requests_threshold - left
|
@@ -37,18 +44,18 @@ module ShopifyAPI
|
|
37
44
|
rescue ActiveResource::ClientError => e
|
38
45
|
case e.response.code
|
39
46
|
when '404'
|
40
|
-
logger.fatal "Shopify returned not found"
|
41
47
|
sleep 5 + retries + (rand * rand * 5)
|
42
48
|
retries += 1
|
43
49
|
if retries < 4
|
44
|
-
ActiveResource::Base.logger
|
50
|
+
ActiveResource::Base.logger ||= Logger.new(STDOUT)
|
51
|
+
ActiveResource::Base.logger.info "Shopify returned not found: #{e.message}. Retrying"
|
45
52
|
retry
|
46
53
|
else
|
47
|
-
ActiveResource::Base.logger =
|
54
|
+
ActiveResource::Base.logger = orig_logger
|
48
55
|
raise
|
49
56
|
end
|
50
57
|
when '429'
|
51
|
-
logger.
|
58
|
+
ActiveResource::Base.logger.info "Shopify hit api limit" if ActiveResource::Base.logger
|
52
59
|
@throttle += rand/5
|
53
60
|
retries += 1
|
54
61
|
sleep (@throttle * 4 * retries) + rand/10
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shopify_unlimited
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.15.threadsafe
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Johnston
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeresource
|