Control the Cloud C++ client library behavior with respect to polling on long running operations.
Some operations in Cloud services return a google.longrunning.Operation object. As their name implies, these objects represent requests that may take a long time to complete, in some cases operations may take tens of seconds or even 30 minutes to complete.
The Cloud C++ client libraries models these long running operations as a google::cloud::future<StatusOr<T>>, where T represents the final result of the operation. In the background, the library polls the service until the operation completes (or fails) and then satisfies the future.
This class defines the interface for policies that control the behavior of this polling loop.
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 >
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.
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 page details the `PollingPolicy` class in the Cloud C++ client library, which manages the behavior of polling loops for long-running operations."],["The latest version available is 2.37.0-rc, while the current page is focused on version 2.29.0, and it also provides access to all other versions ranging from 2.36.0 down to 2.10.1."],["`PollingPolicy` handles `google.longrunning.Operation` objects, which represent operations that might take a long time to complete, by polling the service until the operation is done."],["The class provides functions such as `clone()`, `OnFailure(Status const &)`, and `WaitPeriod()` to control the polling loop, including handling failed attempts and determining wait times between retries."],["Long running operations are modeled as a `google::cloud::future` that returns a `StatusOr\u003cT\u003e`, where T is the end result of the operation."]]],[]]