Class: Gapic::StreamInput

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

Constructor Details

#initialize(*requests) ⇒ StreamInput

Create a new input stream object to manage streaming requests and hold the stream open until #close is called.

Parameters:

  • requests (Object)


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

#closeStreamInput

Closes the stream.

Returns:



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.

Parameters:

  • request (Object)

Returns:



39
40
41
42
43
# File 'lib/gapic/stream_input.rb', line 39

def push request
  @queue.push request

  self
end