require_relative '../../../../../gen/Design.ORiN3.Common/V1/orin3_common_pb' require_relative '../../../../../gen/Message.ORiN3.Provider/V1/orin3_stream_pb' require_relative '../message_client_error' module O3P include Message::ORiN3::Provider::V1::AutoGenerated end module O3 include Design::ORiN3::Common::V1::AutoGenerated include Message::ORiN3::Provider::V1::AutoGenerated::Stream end module Grpc module Client module ORiN3 module Provider class ORiN3Stream < ORiN3BaseObject attr_reader :created_datetime include ORiN3ResourceOpener def initialize(channel, internal_id, created_datetime) @created_datetime = created_datetime super(channel, internal_id) end 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 end end end end end