Class: Gapic::ServiceStub::RpcCall
- Inherits:
-
Object
- Object
- Gapic::ServiceStub::RpcCall
- Defined in:
- lib/gapic/grpc/service_stub/rpc_call.rb
Instance Attribute Summary collapse
-
#stub_method ⇒ Object
readonly
Returns the value of attribute stub_method.
Instance Method Summary collapse
-
#call(request, options: nil) {|response, operation| ... } ⇒ Object
Invoke the RPC call.
-
#initialize(stub_method) ⇒ RpcCall
constructor
Creates an API object for making a single RPC call.
Constructor Details
#initialize(stub_method) ⇒ RpcCall
Creates an API object for making a single RPC call.
In typical usage, stub_method
will be a proc used to make an RPC request. This will mostly likely be a bound
method from a request Stub used to make an RPC call.
The result is created by applying a series of function decorators defined in this module to stub_method
.
The result is another proc which has the same signature as the original.
35 36 37 |
# File 'lib/gapic/grpc/service_stub/rpc_call.rb', line 35 def initialize stub_method @stub_method = stub_method end |
Instance Attribute Details
#stub_method ⇒ Object (readonly)
Returns the value of attribute stub_method.
21 22 23 |
# File 'lib/gapic/grpc/service_stub/rpc_call.rb', line 21 def stub_method @stub_method end |
Instance Method Details
#call(request, options: nil) {|response, operation| ... } ⇒ Object
Invoke the RPC call.
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/gapic/grpc/service_stub/rpc_call.rb', line 114 def call request, options: nil # Converts hash and nil to an options object = Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h deadline = calculate_deadline = . retried_exception = nil begin operation = stub_method.call request, deadline: deadline, metadata: , return_op: true response = operation.execute yield response, operation if block_given? response rescue ::GRPC::DeadlineExceeded => e raise Gapic::GRPC::DeadlineExceededError.new e., root_cause: retried_exception rescue StandardError => e if e.is_a?(::GRPC::Unavailable) && /Signet::AuthorizationError/ =~ e. e = Gapic::GRPC::AuthorizationError.new e..gsub(%r{^\d+:}, "") end if check_retry?(deadline) && .retry_policy.call(e) retried_exception = e retry end raise e end end |