shopify_unlimited 0.0.14.threadsafe → 0.0.15.threadsafe

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MGJhYTI2MWQ4NjQxNjNlODZmN2I3ZTY3MjEzZGQ0MjIxZGZhZDI2ZQ==
4
+ Njc4NjgzNmIxMjBiMDk3MjI2NWJkYmY2ZjZkN2FiYzY2NWQ0ZDMwZQ==
5
5
  data.tar.gz: !binary |-
6
- ZTQzMDliNDE3MGZmY2RiY2E5OTRjYjdkZDRmZjYwNjZhNDQ2ZmE4Yw==
6
+ ODllNjY5ZTFhNTJmZmU1NWU2NWMxZDQ2MzFmZTkzMTk2YWZkMTllMQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NjgyNzMxMTE5NWIyOGQxODAyNWI4YTdkZGUwZjBiNTQwOWQzMWJhZDRiYjNk
10
- MzA3MDI3YTJiOGI4YjNiODRjN2FlNDAxMjI5NTRhNzE5ODVlYTU3NjhmNWRj
11
- MDRjN2RkNmFiNzc1YjRiMWJlN2UwY2QyZTQyMzdlM2U2OWZiNDI=
9
+ MDEyOWEwODYzOTkzNDNmYjg4YTM1OTQ1ZjhhZDY0MjEzMTIxYWQ1MzIyNWQw
10
+ MmM1M2Y3MDE5MjFhYmZhOTg2ZTBiOTZlZTY2Y2EzMjcxYzc4YzkyOGQ5YWU3
11
+ OTQ0YzAyMDBhZDAzNzliZWIxNjM4YjA3NmU4N2NlNGI2NjZkN2Q=
12
12
  data.tar.gz: !binary |-
13
- ZWE3MjM3ODk3NmY3ZGYzNDZjYzI4ZjU4OGZhNGNmNzU1ZGFkNDk1ZDIwYWFj
14
- MjE5OGE2ZjBiNjM1YzFkMjk4NmJhMjQ4YTRhNjVlNWQ3YzU0NTg1MzQzMDY4
15
- ZWQxZDEwNzlkMDRjMjc0ZDhiMGMzMjdlYzZlZGM0MzhhNDM5MWU=
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 = Logger.new(STDOUT)
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 = nil
54
+ ActiveResource::Base.logger = orig_logger
48
55
  raise
49
56
  end
50
57
  when '429'
51
- logger.warn "Shopify hit api limit"
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
@@ -1,3 +1,3 @@
1
1
  module ShopifyUnlimited
2
- VERSION = "0.0.14.threadsafe"
2
+ VERSION = "0.0.15.threadsafe"
3
3
  end
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.14.threadsafe
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-13 00:00:00.000000000 Z
11
+ date: 2014-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeresource