Sha256: 707fd780558f21f9f4190d1ccb1487f9b2c9bc99b008a2994e324fa9c4ade648

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 KB

Contents

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
grpc-orin3-provider-1.0.0 lib/grpc/client/orin3/provider/orin3_stream.rb