Google Cloud C++ Client  1.42.0
C++ Client Library for Google Cloud Platform
Public Member Functions | List of all members
google::cloud::GenericPollingPolicy< Retry, Backoff > Class Template Reference

Construct a polling policy from existing Retry and Backoff policies. More...

#include <google/cloud/polling_policy.h>

Public Member Functions

 GenericPollingPolicy (Retry retry_policy, Backoff backoff_policy)
 
std::unique_ptr< PollingPolicyclone () const override
 Return a copy of the current policy. More...
 
bool OnFailure (Status const &status) override
 A callback to indicate that a polling attempt failed. More...
 
std::chrono::milliseconds WaitPeriod () override
 How long should the polling loop wait before trying again. More...
 

Detailed Description

template<typename Retry, typename Backoff>
class google::cloud::GenericPollingPolicy< Retry, Backoff >

Construct a polling policy from existing Retry and Backoff policies.

A polling policy can be built by composing a retry and backoff policy. For example, to create a polling policy that "retries N times, waiting a fixed period between retries" you could compose the "try N times" retry policy with the "wait a fixed period between retries" backoff policy.

This class makes it easier to create such composed polling policies.

Template Parameters
Retrythe retry policy used to limit the number of errors or the total duration of the polling loop.
Backoffthe backoff policy used to control how often the library polls.

Definition at line 94 of file polling_policy.h.

Constructor & Destructor Documentation

◆ GenericPollingPolicy()

template<typename Retry , typename Backoff >
google::cloud::GenericPollingPolicy< Retry, Backoff >::GenericPollingPolicy ( Retry  retry_policy,
Backoff  backoff_policy 
)
inline

Definition at line 96 of file polling_policy.h.

Member Function Documentation

◆ clone()

template<typename Retry , typename Backoff >
std::unique_ptr<PollingPolicy> google::cloud::GenericPollingPolicy< Retry, Backoff >::clone ( ) const
inlineoverridevirtual

Return a copy of the current policy.

This function is called at the beginning of the polling loop. Policies that are based on relative time should restart their timers when this function is called.

Implements google::cloud::PollingPolicy.

Definition at line 103 of file polling_policy.h.

◆ OnFailure()

template<typename Retry , typename Backoff >
bool google::cloud::GenericPollingPolicy< Retry, Backoff >::OnFailure ( Status const &  status)
inlineoverridevirtual

A callback to indicate that a polling attempt failed.

This is called when a polling request fails. Note that this callback is not invoked when the polling request succeeds with "operation not done".

Returns
true if the failure should be treated as transient and the polling loop should continue.

Implements google::cloud::PollingPolicy.

Definition at line 109 of file polling_policy.h.

◆ WaitPeriod()

template<typename Retry , typename Backoff >
std::chrono::milliseconds google::cloud::GenericPollingPolicy< Retry, Backoff >::WaitPeriod ( )
inlineoverridevirtual

How long should the polling loop wait before trying again.

Implements google::cloud::PollingPolicy.

Definition at line 113 of file polling_policy.h.