restify 1.4.3 → 1.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/restify/adapter/typhoeus.rb +30 -20
- data/lib/restify/error.rb +6 -0
- data/lib/restify/version.rb +1 -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: 05b4120c9755cdd5a88f172e3d5964eff3804add46785bd3cbec8b842f2af459
|
4
|
+
data.tar.gz: 5cb09e31e263560b373b156cfaa601925b9bde328ff892d4533c2738b10dff67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5854443d09b5d6ce73f3a68da7c76e2ed7453288b4e9ef940cfb2e437b8666f0c4f03b6602405193728751b5ee2cf46a12937196d412e3d911d7b497e947daf
|
7
|
+
data.tar.gz: 535598e592a526d20cb8c5d93fe4926deea1d1f92f60bf5fd003115a56841462ad6ce475d96927a09b940524c622e80730ff06c858940c2d08e4ed8396fa8359
|
data/CHANGELOG.md
CHANGED
@@ -18,6 +18,7 @@ module Restify
|
|
18
18
|
@sync = sync
|
19
19
|
@hydra = ::Typhoeus::Hydra.new(**options)
|
20
20
|
@mutex = Mutex.new
|
21
|
+
@signal = ConditionVariable.new
|
21
22
|
end
|
22
23
|
|
23
24
|
def sync?
|
@@ -29,21 +30,28 @@ module Restify
|
|
29
30
|
logger.debug { "[#{request.object_id}] Queue request #{request}" }
|
30
31
|
@hydra.queue convert(request, writer)
|
31
32
|
@hydra.dequeue_many
|
32
|
-
end
|
33
33
|
|
34
|
-
|
34
|
+
if sync?
|
35
|
+
@hydra.run
|
36
|
+
else
|
37
|
+
thread.run
|
38
|
+
@signal.signal
|
39
|
+
end
|
40
|
+
end
|
35
41
|
end
|
36
42
|
|
37
43
|
def queued?
|
38
|
-
@mutex.synchronize
|
39
|
-
@hydra.queued_requests.any? || @hydra.multi.easy_handles.count > 0
|
40
|
-
end
|
44
|
+
@mutex.synchronize { ns_queued? }
|
41
45
|
end
|
42
46
|
|
43
47
|
private
|
44
48
|
|
49
|
+
def ns_queued?
|
50
|
+
@hydra.queued_requests.any? || @hydra.multi.easy_handles.count > 0
|
51
|
+
end
|
52
|
+
|
45
53
|
def convert(request, writer)
|
46
|
-
|
54
|
+
::Typhoeus::Request.new(
|
47
55
|
request.uri,
|
48
56
|
method: request.method,
|
49
57
|
headers: DEFAULT_HEADERS.merge(request.headers),
|
@@ -51,20 +59,19 @@ module Restify
|
|
51
59
|
followlocation: true,
|
52
60
|
timeout: request.timeout,
|
53
61
|
connecttimeout: request.timeout
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
62
|
+
).tap do |req|
|
63
|
+
req.on_complete do |response|
|
64
|
+
logger.debug { "[#{request.object_id}] Completed: #{response.code}" }
|
65
|
+
|
66
|
+
if response.timed_out?
|
67
|
+
writer.reject Restify::Timeout.new request
|
68
|
+
elsif response.code == 0
|
69
|
+
writer.reject Restify::NetworkError.new request, response.return_message
|
70
|
+
else
|
71
|
+
writer.fulfill convert_back(response, request)
|
72
|
+
end
|
64
73
|
end
|
65
74
|
end
|
66
|
-
|
67
|
-
req
|
68
75
|
end
|
69
76
|
|
70
77
|
def convert_back(response, request)
|
@@ -103,8 +110,11 @@ module Restify
|
|
103
110
|
@hydra.run
|
104
111
|
logger.debug { 'Hydra finished' }
|
105
112
|
else
|
106
|
-
|
107
|
-
|
113
|
+
@mutex.synchronize do
|
114
|
+
return if ns_queued?
|
115
|
+
logger.debug { 'Pause hydra thread' }
|
116
|
+
@signal.wait(@mutex)
|
117
|
+
end
|
108
118
|
end
|
109
119
|
rescue StandardError => e
|
110
120
|
logger.error(e)
|
data/lib/restify/error.rb
CHANGED
@@ -19,6 +19,12 @@ module Restify
|
|
19
19
|
# unresolvable hosts or disconnects.
|
20
20
|
#
|
21
21
|
class NetworkError < StandardError
|
22
|
+
attr_reader :request
|
23
|
+
|
24
|
+
def initialize(request, message)
|
25
|
+
@request = request
|
26
|
+
super("[#{request.uri}] #{message}")
|
27
|
+
end
|
22
28
|
end
|
23
29
|
|
24
30
|
# A {ResponseError} is returned on a non-successful
|
data/lib/restify/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Graichen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -185,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
185
|
version: '0'
|
186
186
|
requirements: []
|
187
187
|
rubyforge_project:
|
188
|
-
rubygems_version: 2.7.
|
188
|
+
rubygems_version: 2.7.7
|
189
189
|
signing_key:
|
190
190
|
specification_version: 4
|
191
191
|
summary: An experimental hypermedia REST client.
|