Class: Restate::Server::Handler::StreamingBody
- Inherits:
-
Object
- Object
- Restate::Server::Handler::StreamingBody
- Defined in:
- lib/restate/server/handler.rb
Overview
Rack 3 streaming body that yields chunks from an Async::Queue. Terminates when nil is dequeued.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(queue) ⇒ StreamingBody
constructor
A new instance of StreamingBody.
Constructor Details
#initialize(queue) ⇒ StreamingBody
Returns a new instance of StreamingBody.
240 241 242 |
# File 'lib/restate/server/handler.rb', line 240 def initialize(queue) @queue = queue end |
Instance Method Details
#each ⇒ Object
244 245 246 247 248 249 250 251 |
# File 'lib/restate/server/handler.rb', line 244 def each loop do chunk = @queue.dequeue break if chunk.nil? yield chunk end end |