stripe 5.4.1 → 5.5.0
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 +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile +0 -1
- data/VERSION +1 -1
- data/lib/stripe/stripe_client.rb +18 -14
- data/lib/stripe/util.rb +2 -3
- data/lib/stripe/version.rb +1 -1
- data/test/stripe/stripe_client_test.rb +25 -5
- data/test/test_helper.rb +0 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04bf14074bb94dbb41edf733c9240f770026a9e51647359d4d1d55820c1f3c46
|
4
|
+
data.tar.gz: e5a8433b4284faf095da5ad4ebd102127b005a52b56b7651dadfa579a06188f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e905a1f7fa40887d5c8bd78c428f1d377b42ead6586cf147f6334fafc6264d81ccbdb504e6ef2c8da3e473f40ad18b275f372cc70eea147435252d813ac948b8
|
7
|
+
data.tar.gz: 3d03fb7104356a787b85287455e74157761e92b159db33414685af565fd99e7ff596e9cd1f4ce7dd0e00f44e2c342618fc65f52ad91ed7ccedabd42db6d990c4
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 5.5.0 - 2019-10-03
|
4
|
+
* [#859](https://github.com/stripe/stripe-ruby/pull/859) User-friendly messages and retries for `EOFError`, `Errno::ECONNRESET`, `Errno::ETIMEDOUT`, and `Errno::EHOSTUNREACH` network errors
|
5
|
+
|
3
6
|
## 5.4.1 - 2019-10-01
|
4
7
|
* [#858](https://github.com/stripe/stripe-ruby/pull/858) Drop Timecop dependency
|
5
8
|
|
data/Gemfile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
5.
|
1
|
+
5.5.0
|
data/lib/stripe/stripe_client.rb
CHANGED
@@ -81,17 +81,17 @@ module Stripe
|
|
81
81
|
def self.should_retry?(error, method:, num_retries:)
|
82
82
|
return false if num_retries >= Stripe.max_network_retries
|
83
83
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
84
|
+
case error
|
85
|
+
when Net::OpenTimeout, Net::ReadTimeout
|
86
|
+
# Retry on timeout-related problems (either on open or read).
|
87
|
+
true
|
88
|
+
when EOFError, Errno::ECONNREFUSED, Errno::ECONNRESET,
|
89
|
+
Errno::EHOSTUNREACH, Errno::ETIMEDOUT, SocketError
|
90
|
+
# Destination refused the connection, the connection was reset, or a
|
91
|
+
# variety of other connection failures. This could occur from a single
|
92
|
+
# saturated server, so retry in case it's intermittent.
|
93
|
+
true
|
94
|
+
when Stripe::StripeError
|
95
95
|
# The API may ask us not to retry (e.g. if doing so would be a no-op),
|
96
96
|
# or advise us to retry (e.g. in cases of lock timeouts). Defer to
|
97
97
|
# those instructions if given.
|
@@ -119,10 +119,10 @@ module Stripe
|
|
119
119
|
return true if error.http_status == 500 && method != :post
|
120
120
|
|
121
121
|
# 503 Service Unavailable
|
122
|
-
|
122
|
+
error.http_status == 503
|
123
|
+
else
|
124
|
+
false
|
123
125
|
end
|
124
|
-
|
125
|
-
false
|
126
126
|
end
|
127
127
|
|
128
128
|
def self.sleep_time(num_retries)
|
@@ -296,7 +296,11 @@ module Stripe
|
|
296
296
|
# The original error message is also appended onto the final exception for
|
297
297
|
# full transparency.
|
298
298
|
NETWORK_ERROR_MESSAGES_MAP = {
|
299
|
+
EOFError => ERROR_MESSAGE_CONNECTION,
|
299
300
|
Errno::ECONNREFUSED => ERROR_MESSAGE_CONNECTION,
|
301
|
+
Errno::ECONNRESET => ERROR_MESSAGE_CONNECTION,
|
302
|
+
Errno::EHOSTUNREACH => ERROR_MESSAGE_CONNECTION,
|
303
|
+
Errno::ETIMEDOUT => ERROR_MESSAGE_TIMEOUT_CONNECT,
|
300
304
|
SocketError => ERROR_MESSAGE_CONNECTION,
|
301
305
|
|
302
306
|
Net::OpenTimeout => ERROR_MESSAGE_TIMEOUT_CONNECT,
|
data/lib/stripe/util.rb
CHANGED
@@ -178,9 +178,8 @@ module Stripe
|
|
178
178
|
# to calculate an elapsed duration.
|
179
179
|
#
|
180
180
|
# Shortcut for getting monotonic time, mostly for purposes of line length
|
181
|
-
# and stubbing
|
182
|
-
#
|
183
|
-
# platform (e.g. system boot time).
|
181
|
+
# and test stubbing. Returns time in seconds since the event used for
|
182
|
+
# monotonic reference purposes by the platform (e.g. system boot time).
|
184
183
|
def self.monotonic_time
|
185
184
|
Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
186
185
|
end
|
data/lib/stripe/version.rb
CHANGED
@@ -172,6 +172,26 @@ module Stripe
|
|
172
172
|
method: :post, num_retries: 0)
|
173
173
|
end
|
174
174
|
|
175
|
+
should "retry on EOFError" do
|
176
|
+
assert StripeClient.should_retry?(EOFError.new,
|
177
|
+
method: :post, num_retries: 0)
|
178
|
+
end
|
179
|
+
|
180
|
+
should "retry on Errno::ECONNRESET" do
|
181
|
+
assert StripeClient.should_retry?(Errno::ECONNRESET.new,
|
182
|
+
method: :post, num_retries: 0)
|
183
|
+
end
|
184
|
+
|
185
|
+
should "retry on Errno::ETIMEDOUT" do
|
186
|
+
assert StripeClient.should_retry?(Errno::ETIMEDOUT.new,
|
187
|
+
method: :post, num_retries: 0)
|
188
|
+
end
|
189
|
+
|
190
|
+
should "retry on Errno::EHOSTUNREACH" do
|
191
|
+
assert StripeClient.should_retry?(Errno::EHOSTUNREACH.new,
|
192
|
+
method: :post, num_retries: 0)
|
193
|
+
end
|
194
|
+
|
175
195
|
should "retry on Net::OpenTimeout" do
|
176
196
|
assert StripeClient.should_retry?(Net::OpenTimeout.new,
|
177
197
|
method: :post, num_retries: 0)
|
@@ -316,11 +336,11 @@ module Stripe
|
|
316
336
|
|
317
337
|
context "logging" do
|
318
338
|
setup do
|
319
|
-
# Freeze time for the purposes of the `elapsed` parameter that we
|
320
|
-
# for responses. Mocha's `anything` parameter can't match inside
|
321
|
-
# hash and is therefore not useful for this purpose
|
322
|
-
#
|
323
|
-
#
|
339
|
+
# Freeze time for the purposes of the `elapsed` parameter that we
|
340
|
+
# emit for responses. Mocha's `anything` parameter can't match inside
|
341
|
+
# of a hash and is therefore not useful for this purpose. If we
|
342
|
+
# switch over to rspec-mocks at some point, we can probably remove
|
343
|
+
# this.
|
324
344
|
Util.stubs(:monotonic_time).returns(0.0)
|
325
345
|
end
|
326
346
|
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stripe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Stripe is the easiest way to accept payments online. See https://stripe.com
|
14
14
|
for details.
|
@@ -246,7 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
246
246
|
- !ruby/object:Gem::Version
|
247
247
|
version: '0'
|
248
248
|
requirements: []
|
249
|
-
rubygems_version: 3.0.
|
249
|
+
rubygems_version: 3.0.3
|
250
250
|
signing_key:
|
251
251
|
specification_version: 4
|
252
252
|
summary: Ruby bindings for the Stripe API
|