Skip to content

Commit c290ee3

Browse files
committed
Improved annotations.
1 parent fa04892 commit c290ee3

File tree

7 files changed

+18
-12
lines changed

7 files changed

+18
-12
lines changed

async-http.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
2323

2424
spec.add_dependency("protocol-http", "~> 0.18.0")
2525
spec.add_dependency("protocol-http1", "~> 0.12.0")
26-
spec.add_dependency("protocol-http2", "~> 0.13.0")
26+
spec.add_dependency("protocol-http2", "~> 0.14.0")
2727

2828
# spec.add_dependency("openssl")
2929

lib/async/http/body/pipe.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def close
6060
def reader(task)
6161
@reader = task
6262

63-
task.annotate "pipe reader"
63+
task.annotate "#{self.class} reader."
6464

6565
while chunk = @input.read
6666
@head.write(chunk)
@@ -80,7 +80,7 @@ def reader(task)
8080
def writer(task)
8181
@writer = task
8282

83-
task.annotate "pipe writer"
83+
task.annotate "#{self.class} writer."
8484

8585
while chunk = @head.read_partial
8686
@output.write(chunk)

lib/async/http/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def self.open(*arguments, **options, &block)
8383

8484
def close
8585
while @pool.busy?
86-
Async.logger.warn(self) {"Waiting for pool to drain: #{@pool}"}
86+
Async.logger.warn(self) {"Waiting for #{@protocol} pool to drain: #{@pool}"}
8787
@pool.wait
8888
end
8989

lib/async/http/protocol/http1/server.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def next_request
5656

5757
# Server loop.
5858
def each(task: Task.current)
59-
task.annotate("#{version} reading requests for #{self.class}.")
59+
task.annotate("Reading #{version} requests for #{self.class}.")
6060

6161
while request = next_request
6262
response = yield(request, self)

lib/async/http/protocol/http2/connection.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def http2?
6666
end
6767

6868
def start_connection
69-
@reader ||= read_in_background
69+
@reader || read_in_background
7070
end
7171

7272
def close(error = nil)
@@ -93,7 +93,11 @@ def write_frames(&block)
9393
end
9494

9595
def read_in_background(parent: Task.current)
96+
raise RuntimeError, "Connection is closed!" if closed?
97+
9698
parent.async do |task|
99+
@reader = task
100+
97101
task.annotate("#{version} reading data for #{self.class}.")
98102

99103
begin
@@ -130,7 +134,7 @@ def viable?
130134
end
131135

132136
def reusable?
133-
!(self.closed? || @stream.closed?)
137+
!self.closed?
134138
end
135139

136140
def version

lib/async/http/protocol/http2/server.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def close(error = nil)
6262
end
6363

6464
def each(task: Task.current)
65-
task.annotate("#{version} reading requests for #{self.class}.")
65+
task.annotate("Reading #{version} requests for #{self.class}.")
6666

6767
# It's possible the connection has died before we get here...
6868
@requests&.async do |task, request|

spec/async/http/proxy_spec.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,23 +142,25 @@
142142
upstream = Async::IO::Stream.new(endpoint.connect)
143143
Async.logger.debug(self) {"Connected to #{upstream}..."}
144144

145-
reader = Async do
145+
reader = Async do |task|
146+
task.annotate "Upstream reader."
147+
146148
while chunk = upstream.read_partial
147149
stream.write(chunk)
148150
stream.flush
149151
end
150-
151152
ensure
152153
Async.logger.debug(self) {"Finished reading from upstream..."}
153154
stream.close_write
154155
end
155156

156-
writer = Async do
157+
writer = Async do |task|
158+
task.annotate "Upstream writer."
159+
157160
while chunk = stream.read_partial
158161
upstream.write(chunk)
159162
upstream.flush
160163
end
161-
162164
rescue Async::Wrapper::Cancelled
163165
#ignore
164166
ensure

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy