lucid_shopify 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lucid_shopify/send_throttled_request.rb +9 -5
- data/lib/lucid_shopify/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: d302ee03a14fad6032ab30eb06d07d858a085d3d1befa395716f5def19d999db
|
4
|
+
data.tar.gz: d773c4c5059b0fe0294ad708e5cefe1be1c3c978ca5ad1ca2b40a56467b13ec2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6f5b158605a962be8cdac9bdde5f57bb0102baa1670b1dbd67aa9bcf4b89b74b47b674de44a2336ca3a8d0591246c98c26fe7cf91ce2a8cc81fe6d931173f4b
|
7
|
+
data.tar.gz: ee6ccfadededbe26459382419b8f530bfd09cbc0d85c1b18dedc613f0039f276a3c536b18ddac1f65a2dd2729b46c014ae556c8ba99179a5e7d7553e083005b8
|
@@ -9,19 +9,21 @@ module LucidShopify
|
|
9
9
|
#
|
10
10
|
# @see SendRequest#call
|
11
11
|
#
|
12
|
-
def call(
|
13
|
-
interval
|
12
|
+
def call(request, attempts: default_attempts)
|
13
|
+
interval(build_interval_key(request))
|
14
14
|
|
15
|
-
super
|
15
|
+
super(request, attempts: attempts)
|
16
16
|
end
|
17
17
|
|
18
18
|
#
|
19
19
|
# Sleep for the difference if time since the last request is less than the
|
20
20
|
# MINIMUM_INTERVAL.
|
21
21
|
#
|
22
|
+
# @param interval_key [String]
|
23
|
+
#
|
22
24
|
# @note Throttling is only maintained across a single thread.
|
23
25
|
#
|
24
|
-
private def interval
|
26
|
+
private def interval(interval_key)
|
25
27
|
if Thread.current[interval_key]
|
26
28
|
(timestamp - Thread.current[interval_key]).tap do |n|
|
27
29
|
sleep(Rational(n, 1000)) if n < MINIMUM_INTERVAL
|
@@ -31,10 +33,12 @@ module LucidShopify
|
|
31
33
|
Thread.current[interval_key] = timestamp
|
32
34
|
end
|
33
35
|
|
36
|
+
#
|
37
|
+
# @param request [Request]
|
34
38
|
#
|
35
39
|
# @return [String]
|
36
40
|
#
|
37
|
-
private def
|
41
|
+
private def build_interval_key(request)
|
38
42
|
'%s[%s].timestamp' % [self.class, request.credentials.myshopify_domain]
|
39
43
|
end
|
40
44
|
|