Class: Restate::Server::Handler::StreamingBody

Inherits:
Object
  • Object
show all
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

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

#eachObject



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