async-http 0.50.4 → 0.50.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d28849525da21bccd07dc93b7b19a59f734cc35bfdfbef568fd73d00be2677ce
4
- data.tar.gz: efc93512775ec6c66422b3c24cb178957e7826959a69536c5999f07bbd8dd242
3
+ metadata.gz: fe10cc184257f0419dda2ec007872f881b6e9755b3bc9c16ffc98e530bf303a6
4
+ data.tar.gz: 680a47bf8bfe1bfbdc394834bbaf9dc441f394c19aebedc50c68aa86517f6bc7
5
5
  SHA512:
6
- metadata.gz: 5f6e167dde14dd86e25253127e50163cc956c83983da54033b31825dacb3f2257b4bc53aad7ff0c435a224456ce0a00e79f2180c36cf0992ce3e2fdf4332ec7d
7
- data.tar.gz: d9c3ebf70b76f6eb2b3b3653c52be36f766633ccd10158fa8565113771720243086f29cc2abae2230236f0431f39b90e7d7c9a91daf4cb96323f884e1ca26921
6
+ metadata.gz: 6d3855acb1b0dbcb71b4ffb1fef53197657706cd9bc83a7cb30d347181976c2ff7b6b70b97b58a0ee505a69c16944766c2dc2c4596525c1b53de1bf01281dabe
7
+ data.tar.gz: 62b71cb26b87fa38958ef7e1e524ad5ea9bf385bee4f4698b9b97f09d64b80a4f5787a9a9f03f4ce56179e74b75b548ee51154c8c93856a7ee2ab3990a88896b
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.add_dependency("protocol-http", "~> 0.14.1")
25
25
  spec.add_dependency("protocol-http1", "~> 0.10.0")
26
- spec.add_dependency("protocol-http2", "~> 0.10.0")
26
+ spec.add_dependency("protocol-http2", "~> 0.11.0")
27
27
 
28
28
  # spec.add_dependency("openssl")
29
29
 
@@ -80,4 +80,3 @@ end
80
80
  def head(url)
81
81
  self.fetch(url, method: "HEAD")
82
82
  end
83
-
@@ -0,0 +1,9 @@
1
+
2
+ source "https://rubygems.org"
3
+
4
+ gem "benchmark-ips"
5
+
6
+ gem "async"
7
+ gem "async-http"
8
+
9
+ gem "httpx"
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'benchmark'
4
+
5
+ require 'httpx'
6
+
7
+ require 'async'
8
+ require 'async/barrier'
9
+ require 'async/semaphore'
10
+ require 'async/http/internet'
11
+
12
+ URL = "https://www.codeotaku.com/index"
13
+ REPEATS = 10
14
+
15
+ Benchmark.bmbm do |x|
16
+ x.report("async-http") do
17
+ Async do
18
+ internet = Async::HTTP::Internet.new
19
+
20
+ i = 0
21
+ while i < REPEATS
22
+ response = internet.get(URL)
23
+ response.read
24
+
25
+ i += 1
26
+ end
27
+ ensure
28
+ internet&.close
29
+ end
30
+ end
31
+
32
+ x.report("async-http (pipelined)") do
33
+ Async do |task|
34
+ internet = Async::HTTP::Internet.new
35
+ semaphore = Async::Semaphore.new(100, parent: task)
36
+ barrier = Async::Barrier.new(parent: semaphore)
37
+
38
+ # Warm up the connection pool...
39
+ response = internet.get(URL)
40
+ response.read
41
+
42
+ i = 0
43
+ while i < REPEATS
44
+ barrier.async do
45
+ response = internet.get(URL)
46
+
47
+ response.read
48
+ end
49
+
50
+ i += 1
51
+ end
52
+
53
+ barrier.wait
54
+ ensure
55
+ internet&.close
56
+ end
57
+ end
58
+
59
+ x.report("httpx") do
60
+ i = 0
61
+ while i < REPEATS
62
+ response = HTTPX.get(URL)
63
+
64
+ response.read
65
+
66
+ i += 1
67
+ end
68
+ end
69
+
70
+ x.report("httpx (pipelined)") do
71
+ urls = [URL] * REPEATS
72
+ responses = HTTPX.get(*urls)
73
+
74
+ responses.each do |response|
75
+ response.read
76
+ end
77
+ end
78
+ end
@@ -1,46 +1,66 @@
1
1
  GEM
2
2
  specs:
3
- async (1.10.3)
3
+ async (1.24.2)
4
+ console (~> 1.0)
4
5
  nio4r (~> 2.3)
5
6
  timers (~> 4.1)
6
- async-container (0.6.1)
7
+ async-container (0.16.2)
7
8
  async (~> 1.0)
8
- async-io (~> 1.4)
9
- async-http (0.33.0)
10
- async (~> 1.6)
11
- async-io (~> 1.16)
12
- http-protocol (~> 0.6.0)
13
- async-io (1.16.1)
14
- async (~> 1.3)
9
+ async-io (~> 1.26)
10
+ process-group
11
+ async-http (0.50.5)
12
+ async (~> 1.23)
13
+ async-io (~> 1.27.0)
14
+ async-pool (~> 0.2)
15
+ protocol-http (~> 0.14.1)
16
+ protocol-http1 (~> 0.10.0)
17
+ protocol-http2 (~> 0.11.0)
18
+ async-http-cache (0.1.2)
19
+ async-http
20
+ protocol-http (~> 0.14.4)
21
+ async-io (1.27.4)
22
+ async (~> 1.14)
23
+ async-pool (0.2.0)
24
+ async (~> 1.8)
25
+ build-environment (1.13.0)
15
26
  coderay (1.1.2)
16
- falcon (0.18.13)
17
- async-container (~> 0.6.0)
18
- async-http (~> 0.33.0)
19
- async-io (~> 1.9)
20
- http-protocol (~> 0.6.0)
27
+ console (1.8.2)
28
+ falcon (0.35.6)
29
+ async (~> 1.13)
30
+ async-container (~> 0.16.0)
31
+ async-http (~> 0.50.4)
32
+ async-http-cache (~> 0.1.0)
33
+ async-io (~> 1.22)
34
+ build-environment (~> 1.13)
21
35
  localhost (~> 1.1)
36
+ process-metrics (~> 0.1.0)
22
37
  rack (>= 1.0)
23
- samovar (~> 1.3)
24
- hitimes (1.3.0)
25
- http-hpack (0.1.1)
26
- http-protocol (0.6.0)
27
- http-hpack (~> 0.1.0)
28
- localhost (1.1.4)
38
+ samovar (~> 2.1)
39
+ ffi (1.12.2)
40
+ localhost (1.1.6)
29
41
  mapping (1.1.1)
30
- method_source (0.9.0)
31
- nio4r (2.3.1)
32
- pry (0.11.3)
42
+ method_source (0.9.2)
43
+ nio4r (2.5.2)
44
+ process-group (1.2.1)
45
+ process-terminal (~> 0.2.0)
46
+ process-metrics (0.1.1)
47
+ process-terminal (0.2.0)
48
+ ffi
49
+ protocol-hpack (1.4.2)
50
+ protocol-http (0.14.4)
51
+ protocol-http1 (0.10.2)
52
+ protocol-http (~> 0.13)
53
+ protocol-http2 (0.11.1)
54
+ protocol-hpack (~> 1.4)
55
+ protocol-http (~> 0.2)
56
+ pry (0.12.2)
33
57
  coderay (~> 1.1.0)
34
58
  method_source (~> 0.9.0)
35
- rack (2.0.5)
36
- rainbow (2.2.2)
37
- rake
38
- rake (12.3.1)
39
- samovar (1.9.0)
59
+ rack (2.2.2)
60
+ samovar (2.1.4)
61
+ console (~> 1.0)
40
62
  mapping (~> 1.0)
41
- rainbow (~> 2.0)
42
- timers (4.1.2)
43
- hitimes
63
+ timers (4.3.0)
44
64
 
45
65
  PLATFORMS
46
66
  ruby
@@ -51,4 +71,4 @@ DEPENDENCIES
51
71
  rack
52
72
 
53
73
  BUNDLED WITH
54
- 1.16.5
74
+ 1.17.3
@@ -41,6 +41,10 @@ module Async
41
41
  super(nil, authority, method, path, version, headers, body, protocol)
42
42
  end
43
43
 
44
+ def connection
45
+ @connection
46
+ end
47
+
44
48
  def hijack?
45
49
  true
46
50
  end
@@ -42,6 +42,10 @@ module Async
42
42
  super(version, status, headers, body, protocol)
43
43
  end
44
44
 
45
+ def connection
46
+ @connection
47
+ end
48
+
45
49
  def hijack?
46
50
  @body.nil?
47
51
  end
@@ -51,6 +51,10 @@ module Async
51
51
  @write_frame_guard = Async::Semaphore.new(1)
52
52
  end
53
53
 
54
+ def to_s
55
+ "\#<#{self.class} #{@streams.count} active streams>"
56
+ end
57
+
54
58
  attr :stream
55
59
 
56
60
  def http1?
@@ -105,6 +105,12 @@ module Async
105
105
 
106
106
  return headers
107
107
  end
108
+
109
+ def close(error)
110
+ @request = nil
111
+
112
+ super
113
+ end
108
114
  end
109
115
 
110
116
  def initialize(stream)
@@ -115,6 +121,10 @@ module Async
115
121
 
116
122
  attr :stream
117
123
 
124
+ def connection
125
+ @stream.connection
126
+ end
127
+
118
128
  def valid?
119
129
  @scheme and @method and @path
120
130
  end
@@ -27,7 +27,7 @@ module Async
27
27
  module HTTP
28
28
  module Protocol
29
29
  module HTTP2
30
- # Typically used on the client side for writing a request and reading the incoming response.
30
+ # Typically used on the client side for writing a request and reading the incoming response.
31
31
  class Response < Protocol::Response
32
32
  class Stream < HTTP2::Stream
33
33
  def initialize(*)
@@ -50,7 +50,7 @@ module Async
50
50
  end
51
51
 
52
52
  def accept_push_promise_stream(promised_stream_id, headers)
53
- stream = @connection.accept_push_promise_stream(promised_stream_id, &Stream.method(:accept))
53
+ stream = @connection.accept_push_promise_stream(promised_stream_id, &Stream.method(:create))
54
54
 
55
55
  stream.response.build_request(headers)
56
56
 
@@ -110,7 +110,10 @@ module Async
110
110
  def close(error)
111
111
  super
112
112
 
113
- @response.promises.enqueue nil
113
+ if @response
114
+ @response.promises.enqueue nil
115
+ @response = nil
116
+ end
114
117
 
115
118
  @exception = error
116
119
 
@@ -127,9 +130,12 @@ module Async
127
130
  end
128
131
 
129
132
  attr :stream
130
-
131
133
  attr :request
132
134
 
135
+ def connection
136
+ @stream.connection
137
+ end
138
+
133
139
  def wait
134
140
  @stream.wait
135
141
  end
@@ -129,6 +129,9 @@ module Async
129
129
 
130
130
  while chunk = @body&.read
131
131
  self.write(chunk)
132
+ # TODO this reduces memory usage?
133
+ # chunk.clear unless chunk.frozen?
134
+ # GC.start
132
135
  end
133
136
 
134
137
  self.close_write
@@ -201,7 +204,7 @@ module Async
201
204
  end
202
205
  end
203
206
 
204
- def receive_headers(frame)
207
+ def process_headers(frame)
205
208
  if @headers.nil?
206
209
  @headers = ::Protocol::HTTP::Headers.new
207
210
  self.receive_initial_headers(super, frame.end_stream?)
@@ -34,7 +34,9 @@ module Async
34
34
 
35
35
  # This is generated by server protocols.
36
36
  class Request < ::Protocol::HTTP::Request
37
- attr :connection
37
+ def connection
38
+ nil
39
+ end
38
40
 
39
41
  def hijack?
40
42
  false
@@ -45,8 +47,8 @@ module Async
45
47
  end
46
48
 
47
49
  def peer
48
- if @connection
49
- @connection.peer
50
+ if connection = self.connection
51
+ connection.peer
50
52
  end
51
53
  end
52
54
 
@@ -29,15 +29,17 @@ module Async
29
29
  module Protocol
30
30
  # This is generated by client protocols.
31
31
  class Response < ::Protocol::HTTP::Response
32
- attr :connection
32
+ def connection
33
+ nil
34
+ end
33
35
 
34
36
  def hijack?
35
37
  false
36
38
  end
37
39
 
38
40
  def peer
39
- if @connection
40
- @connection.peer
41
+ if connection = self.connection
42
+ connection.peer
41
43
  end
42
44
  end
43
45
 
@@ -22,6 +22,6 @@
22
22
 
23
23
  module Async
24
24
  module HTTP
25
- VERSION = "0.50.4"
25
+ VERSION = "0.50.5"
26
26
  end
27
27
  end
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.50.4
4
+ version: 0.50.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-08 00:00:00.000000000 Z
11
+ date: 2020-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.10.0
89
+ version: 0.11.0
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
- version: 0.10.0
96
+ version: 0.11.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: async-rspec
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -222,6 +222,8 @@ files:
222
222
  - Rakefile
223
223
  - async-http.gemspec
224
224
  - bake/async/http.rb
225
+ - examples/compare/Gemfile
226
+ - examples/compare/benchmark.rb
225
227
  - examples/fetch/Gemfile
226
228
  - examples/fetch/Gemfile.lock
227
229
  - examples/fetch/README.md