dagger 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dagger.rb +23 -0
  3. data/lib/dagger/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb4982d6515068052558c93a430c1d62c3c95908f4c4f48b945fbd2414d50673
4
- data.tar.gz: e66cbf94eaa46bb61b4a72648b337cc36664703368818d42aaa0b6704d23bdec
3
+ metadata.gz: 6cc49c73a7df566bdb7ce4409c8ffbec30473189431b567ac3367b565115aef8
4
+ data.tar.gz: a6ddb73f492ca4e7976f4d543136973ae19bd40b5d9a94f8a821902ea55163c7
5
5
  SHA512:
6
- metadata.gz: 0e225aa8eddb6f7c2d56ba5883af52836430e05a984313fc4ee345d4186f3b5168dc7bb1979b7dcc35407501d152f9da33a8d2285f103a7a9e178de5771dec74
7
- data.tar.gz: b47405379f7627f120bb3ddfc6a364baf6ff790918367774445f7a9a19151378a3b945cd683371af5d434109f2244ce083c00c08e4387502d515b5d65a580321
6
+ metadata.gz: 923f1402cb9233af4e4d30f969e7cbf57a0ce170dfbc6b128bb24bf52e934b413d8b50e3588ded1ba46fc849d51b03cbd07230be0ccea64695f5c8bb37bb1d2c
7
+ data.tar.gz: 965088cadb748076ad8ee031042459014143bf17f6142132aeb85af03512c28083f0ed9abc94db32539dcb7b0df10300464bee308e32f329ad17085f66d778bb
data/lib/dagger.rb CHANGED
@@ -8,6 +8,7 @@ require 'base64'
8
8
  module Dagger
9
9
 
10
10
  REDIRECT_CODES = [301, 302, 303].freeze
11
+ DEFAULT_RETRY_WAIT = 5.freeze # seconds
11
12
  DEFAULT_HEADERS = {
12
13
  'Accept' => '*/*',
13
14
  'User-Agent' => "Dagger/#{VERSION} (Ruby Net::HTTP Wrapper, like curl)"
@@ -88,6 +89,17 @@ module Dagger
88
89
  end
89
90
 
90
91
  @response = build_response(resp, data || resp.body)
92
+
93
+ rescue Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::EINVAL, Timeout::Error, \
94
+ SocketError, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError, OpenSSL::SSL::SSLError => e
95
+
96
+ if retries = opts[:retries] and retries.to_i > 0
97
+ puts "Got #{e.class}! Retrying in a sec (#{retries} retries left)"
98
+ sleep (opts[:retry_wait] || DEFAULT_RETRY_WAIT)
99
+ get(uri, opts.merge(retries: retries - 1))
100
+ else
101
+ raise
102
+ end
91
103
  end
92
104
 
93
105
  def post(uri, data, options = {})
@@ -135,6 +147,17 @@ module Dagger
135
147
  @http.start unless @http.started?
136
148
  resp, data = @http.send(*args)
137
149
  @response = build_response(resp, data || resp.body)
150
+
151
+ rescue Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::EINVAL, Timeout::Error, \
152
+ SocketError, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError, OpenSSL::SSL::SSLError => e
153
+
154
+ if method.to_s.downcase != 'get' && retries = opts[:retries] and retries.to_i > 0
155
+ puts "Got #{e.class}! Retrying in a sec (#{retries} retries left)"
156
+ sleep (opts[:retry_wait] || DEFAULT_RETRY_WAIT)
157
+ request(method, uri, data, opts.merge(retries: retries - 1))
158
+ else
159
+ raise
160
+ end
138
161
  end
139
162
 
140
163
  def response
@@ -1,6 +1,6 @@
1
1
  module Dagger
2
2
  MAJOR = 1
3
- MINOR = 2
3
+ MINOR = 3
4
4
  PATCH = 0
5
5
 
6
6
  VERSION = [MAJOR, MINOR, PATCH].join('.')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dagger
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomás Pollak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-06 00:00:00.000000000 Z
11
+ date: 2019-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler