dagger 2.0.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dagger.gemspec +2 -2
- data/lib/dagger/connection_manager.rb +1 -1
- data/lib/dagger/version.rb +2 -2
- data/lib/dagger.rb +2 -2
- data/spec/retries_spec.rb +61 -0
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5942c147bb4bcf52ad8d1aa04cb5a44010eb15a6c85877a71b68872d745710c2
|
4
|
+
data.tar.gz: 14654c7a309a5719f0b23d136f62f67a6e995b9ac0d6dff0e697b628acf57f35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f71ee8900cc198365cb0ec64176b0861ebe9e8c295a407b048d6c712806f80453770f336e0b518a3f87338b34be4a110963bfb978fdaafec80b54a885d79466
|
7
|
+
data.tar.gz: ec8bc6f7f374466b4d73fdb5cca061b2cab17918818d72e28c7b03b728cdfe5328e04a79584c483a223dbec2ec767dc10a9e0e562152d561f55c24db3b08bd0e
|
data/dagger.gemspec
CHANGED
@@ -19,8 +19,8 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.add_development_dependency "rspec-mocks"
|
20
20
|
s.add_development_dependency "rspec-expectations"
|
21
21
|
|
22
|
-
s.add_runtime_dependency "oj", "
|
23
|
-
s.add_runtime_dependency "ox", "
|
22
|
+
s.add_runtime_dependency "oj", ">= 2.1"
|
23
|
+
s.add_runtime_dependency "ox", ">= 2.4"
|
24
24
|
|
25
25
|
s.files = `git ls-files`.split("\n")
|
26
26
|
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
data/lib/dagger/version.rb
CHANGED
data/lib/dagger.rb
CHANGED
@@ -40,7 +40,7 @@ module Dagger
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def self.resolve_uri(uri, host = nil, query = nil)
|
43
|
-
uri = host + uri if uri[0] == '/' && host
|
43
|
+
uri = host + uri if uri.to_s[0] == '/' && host
|
44
44
|
uri = parse_uri(uri.to_s)
|
45
45
|
uri.path.sub!(/\?.*|$/, '?' + to_query_string(query)) if query and query.any?
|
46
46
|
uri
|
@@ -91,7 +91,7 @@ module Dagger
|
|
91
91
|
def self.init_connection(uri, opts = {})
|
92
92
|
http = Net::HTTP.new(opts[:ip] || uri.host, uri.port)
|
93
93
|
|
94
|
-
if uri.port == 443
|
94
|
+
if uri.port == 443 || uri.scheme == 'https'
|
95
95
|
http.use_ssl = true if http.respond_to?(:use_ssl=) # persistent does it automatically
|
96
96
|
http.verify_mode = opts[:verify_ssl] === false ? OpenSSL::SSL::VERIFY_NONE : OpenSSL::SSL::VERIFY_PEER
|
97
97
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require './lib/dagger'
|
2
|
+
|
3
|
+
require 'rspec/mocks'
|
4
|
+
require 'rspec/expectations'
|
5
|
+
|
6
|
+
describe 'Retries' do
|
7
|
+
|
8
|
+
def send_request
|
9
|
+
Dagger.get('http://foobar.com/test', opts)
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:fake_http) { double('Net::HTTP', started?: true, "keep_alive_timeout=": true, "open_timeout=": true, "read_timeout=": true) }
|
13
|
+
let(:fake_resp) { double('Net::HTTPResponse', code: 200, body: 'foo') }
|
14
|
+
|
15
|
+
before do
|
16
|
+
allow(Net::HTTP).to receive(:new).at_least(:once).and_return(fake_http)
|
17
|
+
allow(fake_http).to receive(:verify_mode=).and_return(true)
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'on ECONNREFUSED' do
|
21
|
+
|
22
|
+
context 'if no retries option passed' do
|
23
|
+
|
24
|
+
let(:opts) { {} }
|
25
|
+
|
26
|
+
it 'does not retry request, and raises error' do
|
27
|
+
expect(fake_http).to receive(:request).once.and_raise(Errno::ECONNREFUSED)
|
28
|
+
expect { send_request }.to raise_error(Errno::ECONNREFUSED)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'if retries is 1' do
|
34
|
+
|
35
|
+
let(:opts) { { retries: 1, retry_wait: 1 } }
|
36
|
+
|
37
|
+
context 'and it still fails' do
|
38
|
+
|
39
|
+
it 'sends a second request, and raises error' do
|
40
|
+
expect(fake_http).to receive(:request).twice.and_raise(Errno::ECONNREFUSED)
|
41
|
+
expect { send_request }.to raise_error(Errno::ECONNREFUSED)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'and then it works' do
|
47
|
+
|
48
|
+
it 'sends a second request, and does not raise error' do
|
49
|
+
expect(fake_http).to receive(:request).once.and_raise(Errno::ECONNREFUSED)
|
50
|
+
expect(fake_http).to receive(:request).once.and_return(fake_resp)
|
51
|
+
allow(fake_resp).to receive(:[]).with('Content-Type').and_return('text/plain')
|
52
|
+
|
53
|
+
expect(send_request.body).to eq('foo')
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
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: 2.
|
4
|
+
version: 2.1.1
|
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:
|
11
|
+
date: 2023-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -70,28 +70,28 @@ dependencies:
|
|
70
70
|
name: oj
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '2.1'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '2.1'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: ox
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '2.4'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '2.4'
|
97
97
|
description: Dagger.post(url, params).body
|
@@ -120,6 +120,7 @@ files:
|
|
120
120
|
- spec/ip_connect_spec.rb
|
121
121
|
- spec/parsers_spec.rb
|
122
122
|
- spec/persistent_spec.rb
|
123
|
+
- spec/retries_spec.rb
|
123
124
|
- spec/sending_data_spec.rb
|
124
125
|
homepage: https://github.com/tomas/dagger
|
125
126
|
licenses: []
|
@@ -139,8 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
140
|
- !ruby/object:Gem::Version
|
140
141
|
version: 1.3.6
|
141
142
|
requirements: []
|
142
|
-
|
143
|
-
rubygems_version: 2.7.3
|
143
|
+
rubygems_version: 3.4.6
|
144
144
|
signing_key:
|
145
145
|
specification_version: 4
|
146
146
|
summary: Simplified Net::HTTP wrapper.
|