Sha256: cda88aa3582ee991f8d620a31bf792277602b96626b04c44f25a7707a3b201ff

Contents?: true

Size: 1.09 KB

Versions: 6

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

require 'grpc_kit/rpcs'
require 'grpc_kit/calls/client_request_response'

module GrpcKit
  module Rpcs::Client
    class RequestResponse < GrpcKit::Rpcs::ClientRpc
      # @param stream [GrpcKit::Stream::ClientStream]
      # @param request [Object] request message
      # @param metadata [Hash<String, String>]
      # @param timeout [GrpcKit::GrpcTime]
      # @return [Object] response message
      def invoke(stream, request,  metadata: {}, timeout: nil)
        call = GrpcKit::Calls::Client::RequestResponse.new(
          metadata: metadata,
          config: @config,
          timeout: timeout,
          stream: stream,
        )

        Timeout.timeout(timeout&.to_f, GrpcKit::Errors::DeadlineExceeded) do
          if @config.interceptor
            @config.interceptor.intercept(request, call, call.metadata) do |r, c, _|
              call.send_msg(request, last: true)
              call.recv(last: true)
            end
          else
            call.send_msg(request, last: true)
            call.recv(last: true)
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
grpc_kit-0.1.14 lib/grpc_kit/rpcs/client_request_response.rb
grpc_kit-0.1.13 lib/grpc_kit/rpcs/client_request_response.rb
grpc_kit-0.1.12 lib/grpc_kit/rpcs/client_request_response.rb
grpc_kit-0.1.11 lib/grpc_kit/rpcs/client_request_response.rb
grpc_kit-0.1.10 lib/grpc_kit/rpcs/client_request_response.rb
grpc_kit-0.1.9 lib/grpc_kit/rpcs/client_request_response.rb