Class: Grpc::Client::ORiN3::Provider::ORiN3Stream

Inherits:
ORiN3BaseObject show all
Includes:
ORiN3ResourceOpener
Defined in:
lib/grpc/client/orin3/provider/orin3_stream.rb

Instance Attribute Summary collapse

Attributes inherited from ORiN3BaseObject

#name, #option, #orin3_object_type, #type_name

Instance Method Summary collapse

Methods included from ORiN3ResourceOpener

#close, #open

Methods inherited from ORiN3BaseObject

#execute, #get_status, #get_tag, #get_tag_keys, #id, #remove_tag, #set_tag

Constructor Details

#initialize(channel, internal_id, created_datetime) ⇒ ORiN3Stream

Returns a new instance of ORiN3Stream.



22
23
24
25
# File 'lib/grpc/client/orin3/provider/orin3_stream.rb', line 22

def initialize(channel, internal_id, created_datetime)
  @created_datetime = created_datetime
  super(channel, internal_id)
end

Instance Attribute Details

#created_datetimeObject (readonly)

Returns the value of attribute created_datetime.



19
20
21
# File 'lib/grpc/client/orin3/provider/orin3_stream.rb', line 19

def created_datetime
  @created_datetime
end

Instance Method Details

#readObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/grpc/client/orin3/provider/orin3_stream.rb', line 27

def read
  begin
    stream = O3::StreamService::Stub.new(nil, :this_channel_is_insecure, channel_override: @channel)
    request = O3::ReadRequest.new(common: O3P::CommonRequest.new, id: @internal_id)
    responses = stream.read(request)
    responses.each do |response|
      if response.common.result_code != :SUCCEEDED
        raise "Read failed: #{response.common.detail}"
      end
      yield response.value if block_given?
    end
  rescue MessageClientError
    raise
  rescue StandardError => e
    raise MessageClientError.new(e)
  end
end