15#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_POLLING_POLICY_H
16#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_POLLING_POLICY_H
18#include "google/cloud/bigtable/rpc_backoff_policy.h"
19#include "google/cloud/bigtable/rpc_retry_policy.h"
20#include "google/cloud/bigtable/version.h"
21#include "google/cloud/grpc_error_delegate.h"
22#include "google/cloud/polling_policy.h"
23#include <grpcpp/grpcpp.h>
29GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
31
32
33
39
40
41
42
43
44
45
48 virtual void Setup(grpc::ClientContext& context) = 0;
51
52
53
54
60
61
62
66
67
68
69
70
71 virtual bool OnFailure(grpc::Status
const& status) {
76
77
78
79
83
84
88
89
90 virtual std::chrono::milliseconds
WaitPeriod() = 0;
94
95
96
97
98
99
100
101
102
103
104
105
106
107
112 "Retry must derive from RPCRetryPolicy");
114 "Backoff must derive from RPCBackoffPolicy");
118 : retry_prototype_(Retry(defaults)),
119 backoff_prototype_(Backoff(defaults)),
120 retry_clone_(retry_prototype_.clone()),
121 backoff_clone_(backoff_prototype_.clone()) {}
123 : retry_prototype_(std::move(retry)),
124 backoff_prototype_(std::move(backoff)),
125 retry_clone_(retry_prototype_.clone()),
126 backoff_clone_(backoff_prototype_.clone()) {}
131 backoff_prototype_));
134 void Setup(grpc::ClientContext& context)
override {
136 backoff_clone_->
Setup(context
);
149 std::chrono::milliseconds
WaitPeriod()
override {
154 Retry retry_prototype_;
155 Backoff backoff_prototype_;
162 internal::RPCPolicyParameters defaults);
164GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
166namespace bigtable_internal {
167GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
172GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
Implement a simple exponential backoff policy.
Definition: rpc_backoff_policy.h:83
Construct a polling policy from existing Retry and Backoff policies.
Definition: polling_policy.h:110
bool OnFailure(Status const &status) override
Handle an RPC failure.
Definition: polling_policy.h:143
void Setup(grpc::ClientContext &context) override
Definition: polling_policy.h:134
std::chrono::milliseconds WaitPeriod() override
Return for how long we should wait before trying again.
Definition: polling_policy.h:149
std::unique_ptr< PollingPolicy > clone() const override
Return a new copy of this object.
Definition: polling_policy.h:128
bool Exhausted() override
Return true if we cannot try again.
Definition: polling_policy.h:147
GenericPollingPolicy(internal::RPCPolicyParameters defaults)
Definition: polling_policy.h:117
GenericPollingPolicy(Retry retry, Backoff backoff)
Definition: polling_policy.h:122
bool IsPermanentError(Status const &status) override
Return true if status represents a permanent error that cannot be retried.
Definition: polling_policy.h:139
Implement a simple "keep trying for this time" retry policy.
Definition: rpc_retry_policy.h:153
Define the interface for providing asynchronous repetitive call rules.
Definition: polling_policy.h:34
virtual bool OnFailure(Status const &status)=0
Handle an RPC failure.
virtual bool Exhausted()=0
Return true if we cannot try again.
virtual bool IsPermanentError(Status const &status)=0
Return true if status represents a permanent error that cannot be retried.
virtual bool IsPermanentError(grpc::Status const &status)
Return true if status represents a permanent error that cannot be retried.
Definition: polling_policy.h:55
virtual ~PollingPolicy()=default
virtual std::unique_ptr< PollingPolicy > clone() const =0
Return a new copy of this object.
virtual bool OnFailure(grpc::Status const &status)
Handle an RPC failure.
Definition: polling_policy.h:71
virtual std::chrono::milliseconds WaitPeriod()=0
Return for how long we should wait before trying again.
virtual void Setup(grpc::ClientContext &context)=0
Define the interface for controlling how the Bigtable client backsoff from failed RPC operations.
Definition: rpc_backoff_policy.h:44
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.
Define the interface for controlling how the Bigtable client retries RPC operations.
Definition: rpc_retry_policy.h:78
virtual bool OnFailure(Status const &status)=0
Handle an RPC failure.
static bool IsPermanentFailure(Status const &status)
Definition: rpc_retry_policy.h:108
virtual void Setup(grpc::ClientContext &context) const =0
Update the ClientContext for the next call.
Contains all the Cloud Bigtable C++ client APIs.
Definition: admin_client.h:28
std::unique_ptr< PollingPolicy > DefaultPollingPolicy(internal::RPCPolicyParameters defaults)
google::cloud::Status MakeStatusFromRpcError(grpc::Status const &status)