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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 984c779f4d3aaa7e07881169dad03f42417e85da7467a68e4301762b417e8a82
4
- data.tar.gz: a85e72b9ebd882d2c9a40f394b6669303e4b02880e4f9077bb7594eef4f14257
3
+ metadata.gz: 52d7c3cac56c5a6bc3146fe32d68853bd36411718a9a24a23eecb1be5055ef2e
4
+ data.tar.gz: f6164b541570442bd62781338ab391f17d9d6a79cfa3d182960efc3046041b0a
5
5
  SHA512:
6
- metadata.gz: deea19e090d2189044a9d81b425428723fd49b76f5b35f0623aa0b11fd142bcd2f07f5e4001b4e790cbf087afc217067c0efcc4b2c0af16c1ff7755c36e171c2
7
- data.tar.gz: fe7621c89dec61b46d7970a077e323e4fa6518acb4a8372f69c8212eaca619c673699e99e3bd32f8c8446e1ae9c57fc92de03cdd3f7d508600c0ccf6c0462a1c
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 defaults for these
115
- config.on ["5XX", Net::TimeoutError]
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
@@ -1,9 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "shopify_api"
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.1.3"
10
+ VERSION = "0.2.0"
7
11
 
8
12
  class Config # :nodoc:
9
13
  attr_writer :default_wait
@@ -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 = "0.1.3"
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
- spec.add_dependency "shopify_api", ">= 4.0"
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.1.3
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-05-08 00:00:00.000000000 Z
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: :runtime
20
+ type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements: