Class: RailsAiGateway::Proxy::Stream Private
- Inherits:
-
Object
- Object
- RailsAiGateway::Proxy::Stream
- Defined in:
- lib/rails_ai_gateway/proxy.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Bounded queue applies backpressure. Rack closes the body on disconnect.
Instance Method Summary collapse
- #close ⇒ Object private
- #each ⇒ Object private
-
#initialize(queue, thread) ⇒ Stream
constructor
private
A new instance of Stream.
Constructor Details
#initialize(queue, thread) ⇒ Stream
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Stream.
23 24 25 |
# File 'lib/rails_ai_gateway/proxy.rb', line 23 def initialize(queue, thread) @queue, @thread = queue, thread end |
Instance Method Details
#close ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
37 38 39 40 |
# File 'lib/rails_ai_gateway/proxy.rb', line 37 def close @thread.kill if @thread.alive? @thread.join end |
#each ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
27 28 29 30 31 32 33 34 35 |
# File 'lib/rails_ai_gateway/proxy.rb', line 27 def each loop do chunk = @queue.pop break if chunk.nil? yield chunk end ensure close end |