module Async::HTTP::Protocol::HTTP2::Connection
Attributes
count[R]
promises[R]
stream[R]
Public Class Methods
new(*)
click to toggle source
Calls superclass method
# File lib/async/http/protocol/http2/connection.rb, line 44 def initialize(*) super @count = 0 @reader = nil # Writing multiple frames at the same time can cause odd problems if frames are only partially written. So we use a semaphore to ensure frames are written in their entirety. @write_frame_guard = Async::Semaphore.new(1) end
Public Instance Methods
close(error = nil)
click to toggle source
Calls superclass method
# File lib/async/http/protocol/http2/connection.rb, line 72 def close(error = nil) @reader = nil super end
concurrency()
click to toggle source
# File lib/async/http/protocol/http2/connection.rb, line 134 def concurrency self.maximum_concurrent_streams end
http1?()
click to toggle source
# File lib/async/http/protocol/http2/connection.rb, line 60 def http1? false end
http2?()
click to toggle source
# File lib/async/http/protocol/http2/connection.rb, line 64 def http2? true end
peer()
click to toggle source
# File lib/async/http/protocol/http2/connection.rb, line 128 def peer @stream.io end
read_in_background(parent: Task.current)
click to toggle source
# File lib/async/http/protocol/http2/connection.rb, line 95 def read_in_background(parent: Task.current) raise RuntimeError, "Connection is closed!" if closed? parent.async(transient: true) do |task| @reader = task task.annotate("#{version} reading data for #{self.class}.") begin while !self.closed? self.consume_window self.read_frame end rescue SocketError, IOError, EOFError, Errno::ECONNRESET, Errno::EPIPE, Async::Wrapper::Cancelled # Ignore. rescue ::Protocol::HTTP2::GoawayError => error # Error is raised if a response is actively reading from the # connection. The connection is silently closed if GOAWAY is # received outside the request/response cycle. if @reader self.close(error) end ensure # Don't call #close twice. if @reader self.close($!) end end end end
reusable?()
click to toggle source
# File lib/async/http/protocol/http2/connection.rb, line 143 def reusable? !self.closed? end
start_connection()
click to toggle source
# File lib/async/http/protocol/http2/connection.rb, line 68 def start_connection @reader || read_in_background end
to_s()
click to toggle source
# File lib/async/http/protocol/http2/connection.rb, line 54 def to_s "\#<#{self.class} #{@streams.count} active streams>" end
version()
click to toggle source
# File lib/async/http/protocol/http2/connection.rb, line 147 def version VERSION end
viable?()
click to toggle source
Can we use this connection to make requests?
# File lib/async/http/protocol/http2/connection.rb, line 139 def viable? @stream.connected? end
write_frame(frame)
click to toggle source
Calls superclass method
# File lib/async/http/protocol/http2/connection.rb, line 78 def write_frame(frame) # We don't want to write multiple frames at the same time. @write_frame_guard.acquire do super end @stream.flush end
write_frames(&block)
click to toggle source
Calls superclass method
# File lib/async/http/protocol/http2/connection.rb, line 87 def write_frames(&block) @write_frame_guard.acquire do super end @stream.flush end