net-hippie 0.2.0 → 0.2.1

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: 7f64cd42e98caffcf56a025383d07b7defe8991f191597859bfa1b12613127ea
4
- data.tar.gz: ca7ac7d7d44f13e6241f87ff2e31bcf76c1f89051a6c562843ec419ddec0ecc2
3
+ metadata.gz: 67434b7c2a05df319622f04b31b9291b8dee0930860227934795e11ef4dca340
4
+ data.tar.gz: 129bf3cd9211203ba90e46876182e34aeaf383f126831a00018f2bed9ecc7ca7
5
5
  SHA512:
6
- metadata.gz: e4f12a3384fd90f92f0470231c89ba1c2980701b5e3f75ea73751281750276b266c8dbc4f6ad9ab10088e073cf2f3b638c283e06045f6a3984b8e5c2d3e7eeea
7
- data.tar.gz: 26cfa4495ca4ed7edac3f9533d257d199fd24a37e85c55f10c3017159230308799f10acceb9a94d3fb3c64c11fe6ce4495f824fb15d1ac76809590962a614c6d
6
+ metadata.gz: 53c334c26b354ed7ceecf6e4b5a10b220f1be541f4ff746f00e12e3f6e43abbad80865695428d7e80842266ff03040eb7cf238c8f537f2cb4ea2e020a69b8e58
7
+ data.tar.gz: ad30547f207c132e2f8727bc6659a83c7ece2e7fe259feaae42729f48a66a23c4054ecf2c36413838903745426b3c8cb7214a8c6e796ab83193d64cc3d47adf9
@@ -9,4 +9,3 @@ before_script:
9
9
  ci:
10
10
  script:
11
11
  - bin/cibuild
12
-
@@ -2,6 +2,8 @@ sudo: false
2
2
  language: ruby
3
3
  cache: bundler
4
4
  rvm:
5
- - 2.5.1
5
+ - 2.3.8
6
+ - 2.4.5
7
+ - 2.5.3
6
8
  script:
7
9
  - bin/cibuild
@@ -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 16 second
70
- # attempt 6 -> delay 32 second
71
- # attempt 7 -> delay 64 second
72
- # attempt 8 -> delay 128 second
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 = 3 if retries <= 0
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
- delay = (2**n) + rand(0.5) # delay + jitter
81
- warn("`#{error.message}` Retry: #{n + 1}/#{retries} Delay: #{delay}s")
82
- sleep delay
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Net
4
4
  module Hippie
5
- VERSION = '0.2.0'
5
+ VERSION = '0.2.1'
6
6
  end
7
7
  end
@@ -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://www.mokhan.ca/'
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.0
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-10 00:00:00.000000000 Z
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://www.mokhan.ca/
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: []