Class: Gapic::StreamInput
- Inherits:
-
Object
- Object
- Gapic::StreamInput
- Defined in:
- lib/gapic/stream_input.rb
Overview
Manages requests for an input stream and holds the stream open until #close is called.
Instance Method Summary collapse
-
#close ⇒ StreamInput
Closes the stream.
-
#initialize(*requests) ⇒ StreamInput
constructor
Create a new input stream object to manage streaming requests and hold the stream open until #close is called.
-
#push(request) ⇒ StreamInput
(also: #<<, #append)
Adds a request object to the stream.
Constructor Details
#initialize(*requests) ⇒ StreamInput
Create a new input stream object to manage streaming requests and hold the stream open until #close is called.
25 26 27 28 29 30 |
# File 'lib/gapic/stream_input.rb', line 25 def initialize *requests @queue = Queue.new # Push initial requests into the queue requests.each { |request| @queue.push request } end |
Instance Method Details
#close ⇒ StreamInput
Closes the stream.
52 53 54 55 56 |
# File 'lib/gapic/stream_input.rb', line 52 def close @queue.push self self end |
#push(request) ⇒ StreamInput Also known as: <<, append
Adds a request object to the stream.
39 40 41 42 43 |
# File 'lib/gapic/stream_input.rb', line 39 def push request @queue.push request self end |