Class: Raptor::Http2::Writer
- Inherits:
-
Object
- Object
- Raptor::Http2::Writer
- Defined in:
- lib/raptor/http2.rb,
sig/generated/raptor/http2.rbs
Overview
Queues concurrent frame writes while the reactor remains the sole owner of the connection socket.
Instance Method Summary collapse
-
#attach(reactor, connection_id) ⇒ void
Routes subsequent frame writes through the connection's reactor.
-
#attach_body(stream_id, body, finished) ⇒ Boolean
Attaches a response body that outlives its application thread.
-
#initialize(write_timeout:) ⇒ Writer
constructor
Creates a new Writer.
-
#write_frames(socket, frames) ⇒ void
Queues frames for the reactor to write.
Constructor Details
#initialize(write_timeout:) ⇒ Writer
Creates a new Writer.
36 37 38 39 40 |
# File 'lib/raptor/http2.rb', line 36 def initialize(write_timeout:) @reactor = nil @connection_id = nil @write_timeout = write_timeout end |
Instance Method Details
#attach(reactor, connection_id) ⇒ void
This method returns an undefined value.
Routes subsequent frame writes through the connection's reactor.
49 50 51 52 |
# File 'lib/raptor/http2.rb', line 49 def attach(reactor, connection_id) @reactor = reactor @connection_id = connection_id end |
#attach_body(stream_id, body, finished) ⇒ Boolean
Attaches a response body that outlives its application thread.
80 81 82 |
# File 'lib/raptor/http2.rb', line 80 def attach_body(stream_id, body, finished) @reactor.attach_http2_body(@connection_id, stream_id, body, finished) end |
#write_frames(socket, frames) ⇒ void
This method returns an undefined value.
Queues frames for the reactor to write. Before attachment, writes directly so the writer remains usable during connection setup.
62 63 64 65 66 67 68 69 70 |
# File 'lib/raptor/http2.rb', line 62 def write_frames(socket, frames) return if !frames || frames.empty? if @reactor @reactor.write_http2_frames(@connection_id, frames) else Http.socket_write(socket, frames.join, timeout: @write_timeout) rescue nil end end |