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.
Constructors
GenericPollingPolicy(Retry, Backoff)
Parameters
Name
Description
retry_policy
Retry
backoff_policy
Backoff
Functions
virtual clone() const
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.
Returns
Type
Description
std::unique_ptr< PollingPolicy >
virtual OnFailure(Status const &)
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".
Parameter
Name
Description
status
Status const &
Returns
Type
Description
bool
true if the failure should be treated as transient and the polling loop should continue.
virtual WaitPeriod()
How long should the polling loop wait before trying again.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-03-05 UTC."],[[["This webpage details the `GenericPollingPolicy` class within the Google Cloud C++ library, which enables constructing custom polling policies by combining retry and backoff strategies."],["The `GenericPollingPolicy` class is used to define how a system should retry operations, including the intervals between attempts and handling of failures."],["The latest version of the class is `2.37.0-rc`, and the page provides links to the documentation for multiple versions from 2.10.1 through 2.37.0-rc, enabling developers to access documentation relevant to their specific version."],["Key methods of `GenericPollingPolicy` include `clone()`, which creates a copy of the current policy for starting new polling loops, `OnFailure()`, which handles the failure of a polling request, and `WaitPeriod()`, which determines how long to wait before retrying."]]],[]]