async-http 0.23.1 → 0.23.2
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 +4 -4
- data/async-http.gemspec +1 -1
- data/lib/async/http/client.rb +2 -1
- data/lib/async/http/pool.rb +33 -16
- data/lib/async/http/protocol/http11.rb +5 -0
- data/lib/async/http/protocol/http2.rb +8 -1
- data/lib/async/http/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57206755197e6bd15038e9036eb5c6ab74a8942b6b00dae74d15eb999c7bf760
|
4
|
+
data.tar.gz: a59c0f71558d7b1ee34b21485cebda98bd30aef71744e83efd1c321b37622389
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d5e76a534e11c8045540c691882d0c92014bbb208444bfd1dbf265867da06deb324c89d5e04bb5fc28f3e71415d9a821797ac6b3614e6ef4b8b48c9ae115754
|
7
|
+
data.tar.gz: deea701332633244e625b516429ace7ac8892a86945facf3295aa6e81d4503de8db1136253f1cba3214cb4b5ff92b7ed47bf8318a4be5227fc977f25a02fc181
|
data/async-http.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.require_paths = ["lib"]
|
18
18
|
|
19
19
|
spec.add_dependency("async", "~> 1.6")
|
20
|
-
spec.add_dependency("async-io", "~> 1.
|
20
|
+
spec.add_dependency("async-io", "~> 1.11")
|
21
21
|
|
22
22
|
spec.add_dependency("http-2", "~> 0.9.0")
|
23
23
|
# spec.add_dependency("openssl")
|
data/lib/async/http/client.rb
CHANGED
@@ -63,10 +63,11 @@ module Async
|
|
63
63
|
request.authority ||= @authority
|
64
64
|
attempt = 0
|
65
65
|
|
66
|
+
# There is a challenge with how this works. If you have 8 connections in the connection pool and they've all expired, retrying 3 times isn't going to work. We need to, perhaps, on the last retry, initiate a completely new connection.
|
66
67
|
begin
|
67
68
|
attempt += 1
|
68
69
|
|
69
|
-
# As we cache connections, it's possible these connections go bad (e.g. closed by remote host). In this case, we need to try again. It's up to the caller to impose a timeout on this.
|
70
|
+
# As we cache connections, it's possible these connections go bad (e.g. closed by remote host). In this case, we need to try again. It's up to the caller to impose a timeout on this. If this is the last attempt, we force a new connection.
|
70
71
|
connection = @connections.acquire
|
71
72
|
|
72
73
|
response = connection.call(request)
|
data/lib/async/http/pool.rb
CHANGED
@@ -58,17 +58,11 @@ module Async
|
|
58
58
|
|
59
59
|
# Make the resource available and let waiting tasks know that there is something available.
|
60
60
|
def release(resource)
|
61
|
+
# A resource that is not good should also not be reusable.
|
61
62
|
if resource.reusable?
|
62
|
-
|
63
|
-
|
64
|
-
@available[resource] -= 1
|
65
|
-
|
66
|
-
if task = @waiting.pop
|
67
|
-
task.resume
|
68
|
-
end
|
63
|
+
reuse(resource)
|
69
64
|
else
|
70
|
-
|
71
|
-
resource.close
|
65
|
+
retire(resource)
|
72
66
|
end
|
73
67
|
end
|
74
68
|
|
@@ -79,6 +73,24 @@ module Async
|
|
79
73
|
|
80
74
|
protected
|
81
75
|
|
76
|
+
def reuse(resource)
|
77
|
+
Async.logger.debug(self) {"Reuse #{resource}"}
|
78
|
+
|
79
|
+
@available[resource] -= 1
|
80
|
+
|
81
|
+
if task = @waiting.pop
|
82
|
+
task.resume
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def retire(resource)
|
87
|
+
Async.logger.debug(self) {"Retire #{resource}"}
|
88
|
+
|
89
|
+
@available.delete(resource)
|
90
|
+
|
91
|
+
resource.close
|
92
|
+
end
|
93
|
+
|
82
94
|
def wait_for_next_available
|
83
95
|
until resource = next_available
|
84
96
|
@waiting << Fiber.current
|
@@ -88,11 +100,11 @@ module Async
|
|
88
100
|
return resource
|
89
101
|
end
|
90
102
|
|
91
|
-
def
|
103
|
+
def create
|
92
104
|
begin
|
93
105
|
# This might fail, which is okay :)
|
94
106
|
resource = @constructor.call
|
95
|
-
rescue
|
107
|
+
rescue
|
96
108
|
Async.logger.error "#{$!}: #{$!.backtrace}"
|
97
109
|
return nil
|
98
110
|
end
|
@@ -102,19 +114,24 @@ module Async
|
|
102
114
|
return resource
|
103
115
|
end
|
104
116
|
|
105
|
-
# TODO this does not take into account resources that start off good but can fail.
|
106
117
|
def next_available
|
107
118
|
@available.each do |resource, count|
|
108
119
|
if count < resource.multiplex
|
109
|
-
|
110
|
-
|
111
|
-
|
120
|
+
# We want to use this resource... but is it good?
|
121
|
+
if resource.good?
|
122
|
+
@available[resource] += 1
|
123
|
+
|
124
|
+
return resource
|
125
|
+
else
|
126
|
+
retire(resource)
|
127
|
+
end
|
112
128
|
end
|
113
129
|
end
|
114
130
|
|
115
131
|
if !@limit or @available.count < @limit
|
116
132
|
Async.logger.debug(self) {"No available resources, allocating new one..."}
|
117
|
-
|
133
|
+
|
134
|
+
return create
|
118
135
|
end
|
119
136
|
end
|
120
137
|
end
|
@@ -70,7 +70,7 @@ module Async
|
|
70
70
|
Async.logger.error(self) {"goaway: #{payload.inspect}"}
|
71
71
|
|
72
72
|
@reader.stop
|
73
|
-
@stream.
|
73
|
+
@stream.close
|
74
74
|
end
|
75
75
|
|
76
76
|
@count = 0
|
@@ -83,6 +83,11 @@ module Async
|
|
83
83
|
@controller.remote_settings[:settings_max_concurrent_streams]
|
84
84
|
end
|
85
85
|
|
86
|
+
# Can we use this connection to make requests?
|
87
|
+
def good?
|
88
|
+
@stream.connected?
|
89
|
+
end
|
90
|
+
|
86
91
|
def reusable?
|
87
92
|
!@stream.closed?
|
88
93
|
end
|
@@ -149,6 +154,8 @@ module Async
|
|
149
154
|
end
|
150
155
|
|
151
156
|
stream.on(:half_close) do
|
157
|
+
# The requirements for this to be in lock-step with other opertaions is minimal.
|
158
|
+
# TODO consider putting this in it's own async task.
|
152
159
|
begin
|
153
160
|
# We are no longer receiving any more data frames:
|
154
161
|
body.finish
|
data/lib/async/http/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.23.
|
4
|
+
version: 0.23.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.11'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
40
|
+
version: '1.11'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: http-2
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|