net-hippie 0.2.0 → 0.2.1
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/.gitlab-ci.yml +0 -1
- data/.travis.yml +3 -1
- data/lib/net/hippie/client.rb +23 -16
- data/lib/net/hippie/version.rb +1 -1
- data/net-hippie.gemspec +3 -3
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67434b7c2a05df319622f04b31b9291b8dee0930860227934795e11ef4dca340
|
4
|
+
data.tar.gz: 129bf3cd9211203ba90e46876182e34aeaf383f126831a00018f2bed9ecc7ca7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53c334c26b354ed7ceecf6e4b5a10b220f1be541f4ff746f00e12e3f6e43abbad80865695428d7e80842266ff03040eb7cf238c8f537f2cb4ea2e020a69b8e58
|
7
|
+
data.tar.gz: ad30547f207c132e2f8727bc6659a83c7ece2e7fe259feaae42729f48a66a23c4054ecf2c36413838903745426b3c8cb7214a8c6e796ab83193d64cc3d47adf9
|
data/.gitlab-ci.yml
CHANGED
data/.travis.yml
CHANGED
data/lib/net/hippie/client.rb
CHANGED
@@ -62,24 +62,21 @@ module Net
|
|
62
62
|
execute(uri, request, &block)
|
63
63
|
end
|
64
64
|
|
65
|
-
# attempt 1 -> delay 1 second
|
66
|
-
# attempt 2 -> delay 2 second
|
67
|
-
# attempt 3 -> delay 4 second
|
68
|
-
# attempt 4 -> delay 8 second
|
69
|
-
# attempt 5 -> delay
|
70
|
-
# attempt 6 -> delay
|
71
|
-
# attempt 7 -> delay
|
72
|
-
# attempt 8 -> delay
|
65
|
+
# attempt 1 -> delay 0.1 second
|
66
|
+
# attempt 2 -> delay 0.2 second
|
67
|
+
# attempt 3 -> delay 0.4 second
|
68
|
+
# attempt 4 -> delay 0.8 second
|
69
|
+
# attempt 5 -> delay 1.6 second
|
70
|
+
# attempt 6 -> delay 3.2 second
|
71
|
+
# attempt 7 -> delay 6.4 second
|
72
|
+
# attempt 8 -> delay 12.8 second
|
73
73
|
def with_retry(retries: 3)
|
74
|
-
retries =
|
75
|
-
0.upto(retries) do |n|
|
76
|
-
return yield self
|
77
|
-
rescue *::Net::Hippie::CONNECTION_ERRORS => error
|
78
|
-
raise error if n >= retries
|
74
|
+
retries = 0 if retries.nil? || retries.negative?
|
79
75
|
|
80
|
-
|
81
|
-
|
82
|
-
|
76
|
+
0.upto(retries) do |n|
|
77
|
+
attempt(n, retries) do
|
78
|
+
return yield self
|
79
|
+
end
|
83
80
|
end
|
84
81
|
end
|
85
82
|
|
@@ -89,6 +86,16 @@ module Net
|
|
89
86
|
attr_reader :verify_mode
|
90
87
|
attr_reader :certificate, :key, :passphrase
|
91
88
|
|
89
|
+
def attempt(attempt, max)
|
90
|
+
yield
|
91
|
+
rescue *CONNECTION_ERRORS => error
|
92
|
+
raise error if attempt == max
|
93
|
+
|
94
|
+
delay = ((2**attempt) * 0.1) + Random.rand(0.05) # delay + jitter
|
95
|
+
warn("`#{error.message}` Retry: #{attempt + 1}/#{max} Delay: #{delay}s")
|
96
|
+
sleep delay
|
97
|
+
end
|
98
|
+
|
92
99
|
def http_for(uri)
|
93
100
|
http = Net::HTTP.new(uri.host, uri.port)
|
94
101
|
http.read_timeout = read_timeout
|
data/lib/net/hippie/version.rb
CHANGED
data/net-hippie.gemspec
CHANGED
@@ -10,9 +10,9 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.authors = ['mo']
|
11
11
|
spec.email = ['mo@mokhan.ca']
|
12
12
|
|
13
|
-
spec.summary = 'net/http for hippies.'
|
14
|
-
spec.description = 'net/http for hippies.'
|
15
|
-
spec.homepage = 'https://
|
13
|
+
spec.summary = 'net/http for hippies. ☮️ '
|
14
|
+
spec.description = 'net/http for hippies. ☮️ '
|
15
|
+
spec.homepage = 'https://github.com/mokhan/net-hippie/'
|
16
16
|
spec.license = 'MIT'
|
17
17
|
|
18
18
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: net-hippie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,7 +94,7 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '3.4'
|
97
|
-
description: net/http for hippies.
|
97
|
+
description: 'net/http for hippies. ☮️ '
|
98
98
|
email:
|
99
99
|
- mo@mokhan.ca
|
100
100
|
executables:
|
@@ -123,7 +123,7 @@ files:
|
|
123
123
|
- lib/net/hippie/content_type_mapper.rb
|
124
124
|
- lib/net/hippie/version.rb
|
125
125
|
- net-hippie.gemspec
|
126
|
-
homepage: https://
|
126
|
+
homepage: https://github.com/mokhan/net-hippie/
|
127
127
|
licenses:
|
128
128
|
- MIT
|
129
129
|
metadata: {}
|
@@ -146,5 +146,5 @@ rubyforge_project:
|
|
146
146
|
rubygems_version: 2.7.6
|
147
147
|
signing_key:
|
148
148
|
specification_version: 4
|
149
|
-
summary: net/http for hippies.
|
149
|
+
summary: net/http for hippies. ☮️
|
150
150
|
test_files: []
|