restify 0.1.1.1.b22 → 0.1.1.1.b24
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 +8 -8
- data/lib/restify/adapter.rb +30 -12
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YTcxMzkwODU2OGRjZmRlMzFhNTQ3N2NjNTYwMGQ0ZDk0NDVhMjg1Mw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Y2UzMzYxMTdlZWRkNmY5YzNjNDZhMGFiMDkyZTk5MGVlZjdhNTdmNQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDk5MTI0Zjg4NzMxZjYxMGFmNDU2NTQzNGVmZWRhYTYwMGVjOGFjZmRjNzdk
|
10
|
+
OTNmNGFkOGVmNzYzNDRiOWYyYjcxMDI3YmMwZTMzYzA1N2ZjNjM2Yzg3ZTAy
|
11
|
+
YzZhNDQ1N2ZjZTlhMDM3ZDdhY2U2OGMwM2ZkMDM1NjE5NGIzZGY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OGVkNWFhNWNhODY3NGU2ZWRmOTYwYmY0YzRmOWZmOTJmZTFiYTZiYWJmMzRl
|
14
|
+
ZjRkMWQzY2Y2ZjMwNjIwYTY5OWRlN2YzZWM5N2NmNWY2Y2Q5ZDRiYmNjNTIw
|
15
|
+
MzEyNmM3N2UyMWU2MTIyZDYzNjU0NDZkY2NjMjZlNjY1ZjBkYTk=
|
data/lib/restify/adapter.rb
CHANGED
@@ -20,26 +20,35 @@ module Restify
|
|
20
20
|
attr_reader :origin
|
21
21
|
|
22
22
|
def initialize(origin)
|
23
|
-
@origin
|
23
|
+
@origin = origin
|
24
|
+
@pipeline = true
|
24
25
|
end
|
25
26
|
|
26
27
|
def requests
|
27
28
|
@requests ||= []
|
28
29
|
end
|
29
30
|
|
30
|
-
def call(request, writer)
|
31
|
-
requests
|
32
|
-
|
31
|
+
def call(request, writer, retried = false)
|
32
|
+
if requests.empty?
|
33
|
+
requests << [request, writer, retried]
|
34
|
+
process_next
|
35
|
+
else
|
36
|
+
requests << [request, writer, retried]
|
37
|
+
end
|
33
38
|
end
|
34
39
|
|
35
40
|
def connection
|
36
41
|
@connection ||= EventMachine::HttpRequest.new(origin)
|
37
42
|
end
|
38
43
|
|
44
|
+
def pipeline?
|
45
|
+
@pipeline
|
46
|
+
end
|
47
|
+
|
39
48
|
def process_next
|
40
49
|
return if requests.empty?
|
41
50
|
|
42
|
-
request, writer = requests.first
|
51
|
+
request, writer, retried = pipeline? ? requests.shift : requests.first
|
43
52
|
req = connection.send request.method.downcase,
|
44
53
|
keepalive: true,
|
45
54
|
redirects: 3,
|
@@ -49,7 +58,7 @@ module Restify
|
|
49
58
|
head: request.headers
|
50
59
|
|
51
60
|
req.callback do
|
52
|
-
requests.shift
|
61
|
+
requests.shift unless pipeline?
|
53
62
|
|
54
63
|
writer.fulfill Response.new(
|
55
64
|
request,
|
@@ -67,14 +76,23 @@ module Restify
|
|
67
76
|
end
|
68
77
|
|
69
78
|
req.errback do
|
70
|
-
requests.shift
|
79
|
+
requests.shift unless pipeline?
|
71
80
|
@connection = nil
|
72
81
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
82
|
+
if pipeline?
|
83
|
+
EventMachine.next_tick do
|
84
|
+
@pipeline = false
|
85
|
+
call request, writer
|
86
|
+
end
|
87
|
+
elsif !retried
|
88
|
+
EventMachine.next_tick { call request, writer }
|
89
|
+
else
|
90
|
+
begin
|
91
|
+
raise RuntimeError.new \
|
92
|
+
"(#{req.response_header.status}) #{req.error}"
|
93
|
+
rescue => e
|
94
|
+
writer.reject e
|
95
|
+
end
|
78
96
|
end
|
79
97
|
end
|
80
98
|
end
|