15#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_RPC_BACKOFF_POLICY_H
16#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_RPC_BACKOFF_POLICY_H
18#include "google/cloud/bigtable/internal/rpc_policy_parameters.h"
19#include "google/cloud/bigtable/version.h"
20#include "google/cloud/internal/backoff_policy.h"
21#include <grpcpp/grpcpp.h>
28GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
30
31
32
33
34
35
36
37
38
39
40
41
42
43
49
50
51
52
53
54
55
59
60
61 virtual void Setup(grpc::ClientContext& context)
const = 0;
64
65
66
67
68
71 virtual std::chrono::milliseconds
OnCompletion(grpc::Status
const& s) = 0;
78 internal::RPCPolicyParameters defaults);
81
82
87 template <
typename Rep1,
typename Period1,
typename Rep2,
typename Period2>
89 std::chrono::duration<Rep2, Period2> maximum_delay)
90 : initial_delay_(std::chrono::duration_cast<std::chrono::microseconds>(
92 maximum_delay_(std::chrono::duration_cast<std::chrono::microseconds>(
94 impl_(initial_delay_ / 2, maximum_delay_, 2.0) {}
97 void Setup(grpc::ClientContext& context)
const override;
100 std::chrono::milliseconds
OnCompletion(grpc::Status
const& status)
override;
103 std::chrono::microseconds initial_delay_;
104 std::chrono::microseconds maximum_delay_;
106 using Impl = ::
google::
cloud::internal::ExponentialBackoffPolicy;
110GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
112namespace bigtable_internal {
113GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
115std::unique_ptr<internal::BackoffPolicy> MakeCommonBackoffPolicy(
118GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
Implement a simple exponential backoff policy.
Definition: rpc_backoff_policy.h:83
std::chrono::milliseconds OnCompletion(grpc::Status const &status) override
std::chrono::milliseconds OnCompletion(Status const &status) override
Return the delay after an RPC operation has completed.
ExponentialBackoffPolicy(internal::RPCPolicyParameters defaults)
std::unique_ptr< RPCBackoffPolicy > clone() const override
Return a new copy of this object.
ExponentialBackoffPolicy(std::chrono::duration< Rep1, Period1 > initial_delay, std::chrono::duration< Rep2, Period2 > maximum_delay)
Definition: rpc_backoff_policy.h:88
void Setup(grpc::ClientContext &context) const override
Update the ClientContext for the next call.
Define the interface for controlling how the Bigtable client backsoff from failed RPC operations.
Definition: rpc_backoff_policy.h:44
std::chrono::milliseconds OnCompletion()
Definition: rpc_backoff_policy.h:73
virtual std::unique_ptr< RPCBackoffPolicy > clone() const =0
Return a new copy of this object.
virtual ~RPCBackoffPolicy()=default
virtual std::chrono::milliseconds OnCompletion(grpc::Status const &s)=0
virtual void Setup(grpc::ClientContext &context) const =0
Update the ClientContext for the next call.
virtual std::chrono::milliseconds OnCompletion(Status const &status)=0
Return the delay after an RPC operation has completed.
Contains all the Cloud Bigtable C++ client APIs.
Definition: admin_client.h:28
std::unique_ptr< RPCBackoffPolicy > DefaultRPCBackoffPolicy(internal::RPCPolicyParameters defaults)
Return an instance of the default RPCBackoffPolicy.