Method: GRPC::ClientStub#request_response
- Defined in:
- src/ruby/lib/grpc/generic/client_stub.rb
#request_response(method, req, marshal, unmarshal, deadline: nil, return_op: false, parent: nil, credentials: nil, metadata: {}) ⇒ Object
request_response sends a request to a GRPC server, and returns the response.
Flow Control ==
This is a blocking call.
-
it does not return until a response is received.
-
the requests is sent only when GRPC core’s flow control allows it to be sent.
Errors ==
An RuntimeError is raised if
-
the server responds with a non-OK status
-
the deadline is exceeded
Return Value ==
If return_op is false, the call returns the response
If return_op is true, the call returns an Operation, calling execute on the Operation returns the response.
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'src/ruby/lib/grpc/generic/client_stub.rb', line 150 def request_response(method, req, marshal, unmarshal, deadline: nil, return_op: false, parent: nil, credentials: nil, metadata: {}) c = new_active_call(method, marshal, unmarshal, deadline: deadline, parent: parent, credentials: credentials) interception_context = @interceptors.build_context intercept_args = { method: method, request: req, call: c.interceptable, metadata: } if return_op # return the operation view of the active_call; define #execute as a # new method for this instance that invokes #request_response. c.() op = c.operation op.define_singleton_method(:execute) do interception_context.intercept!(:request_response, intercept_args) do c.request_response(req, metadata: ) end end op else interception_context.intercept!(:request_response, intercept_args) do c.request_response(req, metadata: ) end end end |