Module: Async::HTTP::Protocol::HTTP2::Connection
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#promises ⇒ Object
readonly
Returns the value of attribute promises.
-
#stream ⇒ Object
readonly
Returns the value of attribute stream.
Instance Method Summary collapse
- #close(error = nil) ⇒ Object
- #concurrency ⇒ Object
- #http1? ⇒ Boolean
- #http2? ⇒ Boolean
- #initialize ⇒ Object
- #peer ⇒ Object
- #read_in_background(task: Task.current) ⇒ Object
- #reusable? ⇒ Boolean
- #start_connection ⇒ Object
- #version ⇒ Object
-
#viable? ⇒ Boolean
Can we use this connection to make requests?.
- #write_frame(frame) ⇒ Object
- #write_frames(&block) ⇒ Object
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
114 115 116 |
# File 'lib/async/http/protocol/http2/connection.rb', line 114 def count @count end |
#promises ⇒ Object (readonly)
Returns the value of attribute promises.
108 109 110 |
# File 'lib/async/http/protocol/http2/connection.rb', line 108 def promises @promises end |
#stream ⇒ Object (readonly)
Returns the value of attribute stream.
54 55 56 |
# File 'lib/async/http/protocol/http2/connection.rb', line 54 def stream @stream end |
Instance Method Details
#close(error = nil) ⇒ Object
68 69 70 71 72 |
# File 'lib/async/http/protocol/http2/connection.rb', line 68 def close(error = nil) @reader = nil super end |
#concurrency ⇒ Object
116 117 118 |
# File 'lib/async/http/protocol/http2/connection.rb', line 116 def concurrency self.maximum_concurrent_streams end |
#http1? ⇒ Boolean
56 57 58 |
# File 'lib/async/http/protocol/http2/connection.rb', line 56 def http1? false end |
#http2? ⇒ Boolean
60 61 62 |
# File 'lib/async/http/protocol/http2/connection.rb', line 60 def http2? true end |
#initialize ⇒ Object
44 45 46 47 48 49 50 51 52 |
# 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 |
#peer ⇒ Object
110 111 112 |
# File 'lib/async/http/protocol/http2/connection.rb', line 110 def peer @stream.io end |
#read_in_background(task: Task.current) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/async/http/protocol/http2/connection.rb', line 91 def read_in_background(task: Task.current) task.async do |nested_task| nested_task.annotate("#{version} reading data for #{self.class}.") begin while !self.closed? self.consume_window self.read_frame end rescue IOError, EOFError, Errno::ECONNRESET, Errno::EPIPE, Async::Wrapper::Cancelled # Ignore. ensure close($!) end end end |
#reusable? ⇒ Boolean
125 126 127 |
# File 'lib/async/http/protocol/http2/connection.rb', line 125 def reusable? !(self.closed? || @stream.closed?) end |
#start_connection ⇒ Object
64 65 66 |
# File 'lib/async/http/protocol/http2/connection.rb', line 64 def start_connection @reader ||= read_in_background end |
#version ⇒ Object
129 130 131 |
# File 'lib/async/http/protocol/http2/connection.rb', line 129 def version VERSION end |
#viable? ⇒ Boolean
Can we use this connection to make requests?
121 122 123 |
# File 'lib/async/http/protocol/http2/connection.rb', line 121 def viable? @stream.connected? end |
#write_frame(frame) ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'lib/async/http/protocol/http2/connection.rb', line 74 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) ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/async/http/protocol/http2/connection.rb', line 83 def write_frames(&block) @write_frame_guard.acquire do super end @stream.flush end |