restify 0.1.1.1.b22 → 0.1.1.1.b24

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +8 -8
  2. data/lib/restify/adapter.rb +30 -12
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YmU3OTMyNjA1OTU3NjFlNTc1ODY2MDIzOTE3MjhhNzA5ZDk1MzdlYw==
4
+ YTcxMzkwODU2OGRjZmRlMzFhNTQ3N2NjNTYwMGQ0ZDk0NDVhMjg1Mw==
5
5
  data.tar.gz: !binary |-
6
- YjZiMDg0ZTYyZTJmMTQ0YTJlYjc1NDBiNTAwZjM1YmJhODE2MGRlZQ==
6
+ Y2UzMzYxMTdlZWRkNmY5YzNjNDZhMGFiMDkyZTk5MGVlZjdhNTdmNQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NTlhMWRhOTM5ODNiYzZlMzk3MmE3YTEwZmI1OTM2OGRlZTNiMWVlNjUwZmVi
10
- NzYyMWJhYmYyMzBkZTdmOGJlYTBhNGI3YzYxZjIxNTYyZmQyM2UwYTczNGRh
11
- OGIzMzYyZGI5YmFhNjQyOTE1YWM2MTRkYzc3NjYwZWM5YjdjZTU=
9
+ ZDk5MTI0Zjg4NzMxZjYxMGFmNDU2NTQzNGVmZWRhYTYwMGVjOGFjZmRjNzdk
10
+ OTNmNGFkOGVmNzYzNDRiOWYyYjcxMDI3YmMwZTMzYzA1N2ZjNjM2Yzg3ZTAy
11
+ YzZhNDQ1N2ZjZTlhMDM3ZDdhY2U2OGMwM2ZkMDM1NjE5NGIzZGY=
12
12
  data.tar.gz: !binary |-
13
- OWFjNjc0YWY0ZjJmMWYwMzRlMzA0ZTlkNjFiYmJhN2VkYmIwZjcwOWVlZjBh
14
- MGJhNjQ5ZTNiYjBiY2JiMGY2ZmFlZTEwN2Q4OTYzMjYzNDUxODIzODM0NDZl
15
- ZGQzY2UxNTJmMzgwNTY3MGE3ZDk0YTYyNzllMTU2ODIzNGNjOTM=
13
+ OGVkNWFhNWNhODY3NGU2ZWRmOTYwYmY0YzRmOWZmOTJmZTFiYTZiYWJmMzRl
14
+ ZjRkMWQzY2Y2ZjMwNjIwYTY5OWRlN2YzZWM5N2NmNWY2Y2Q5ZDRiYmNjNTIw
15
+ MzEyNmM3N2UyMWU2MTIyZDYzNjU0NDZkY2NjMjZlNjY1ZjBkYTk=
@@ -20,26 +20,35 @@ module Restify
20
20
  attr_reader :origin
21
21
 
22
22
  def initialize(origin)
23
- @origin = 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 << [request, writer]
32
- process_next if requests.size == 1
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
- begin
74
- raise RuntimeError.new \
75
- "(#{req.response_header.status}) #{req.error}"
76
- rescue => e
77
- writer.reject e
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1.1.b22
4
+ version: 0.1.1.1.b24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Graichen