Class: Restate::Server::StreamingBody
- Inherits:
-
Object
- Object
- Restate::Server::StreamingBody
- Defined in:
- lib/restate/server.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.
238 239 240 |
# File 'lib/restate/server.rb', line 238 def initialize(queue) @queue = queue end |
Instance Method Details
#each ⇒ Object
242 243 244 245 246 247 248 249 |
# File 'lib/restate/server.rb', line 242 def each loop do chunk = @queue.dequeue break if chunk.nil? yield chunk end end |