The google::cloud::bigtable::RPCRetryPolicy classes have special member functions to setup a timeout:
|
/** |
|
* Update the ClientContext for the next call. |
|
*/ |
|
virtual void Setup(grpc::ClientContext& context) const = 0; |
|
void LimitedTimeRetryPolicy::Setup(grpc::ClientContext& context) const { |
|
if (context.deadline() >= impl_.deadline()) { |
|
context.set_deadline(impl_.deadline()); |
|
} |
|
} |
This is used in the synchronous retry loop, e.g.:
|
while (true) { |
|
grpc::ClientContext client_context; |
|
rpc_policy->Setup(client_context); |
|
backoff_policy->Setup(client_context); |
|
metadata_update_policy_.Setup(client_context); |
|
status = client_->MutateRow(&client_context, request, &response); |
But not in the asynchronous retry loop:
|
static void StartIteration(std::shared_ptr<RetryAsyncUnaryRpc> self, |
|
CompletionQueue cq) { |
|
auto context = absl::make_unique<grpc::ClientContext>(); |
|
|
|
cq.MakeUnaryRpc(self->async_call_, self->request_, std::move(context)) |
That asynchronous retry loop is used in spanner too, and the RetryPolicy for spanner does not have a Setup() member function. Furthermore, the same retry policy class is used in storage, where we would't want to introduce it (because that would create an unwanted dependency on gRPC).
We need a cleaner way to setup per-RPC timeouts across all services, with good support for REST, and we need to use that on the asynchronous and synchronous loops.
The
google::cloud::bigtable::RPCRetryPolicyclasses have special member functions to setup a timeout:google-cloud-cpp/google/cloud/bigtable/rpc_retry_policy.h
Lines 98 to 101 in 81adbda
google-cloud-cpp/google/cloud/bigtable/rpc_retry_policy.cc
Lines 53 to 57 in 81adbda
This is used in the synchronous retry loop, e.g.:
google-cloud-cpp/google/cloud/bigtable/table.cc
Lines 90 to 95 in 81adbda
But not in the asynchronous retry loop:
google-cloud-cpp/google/cloud/internal/async_retry_unary_rpc.h
Lines 145 to 149 in 81adbda
That asynchronous retry loop is used in spanner too, and the
RetryPolicyfor spanner does not have aSetup()member function. Furthermore, the same retry policy class is used in storage, where we would't want to introduce it (because that would create an unwanted dependency on gRPC).We need a cleaner way to setup per-RPC timeouts across all services, with good support for REST, and we need to use that on the asynchronous and synchronous loops.