Class: Restate::Server::StreamingBody

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

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

#eachObject



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