Google Cloud C++ Client  1.32.1
C++ Client Library for Google Cloud Platform
Public Member Functions | List of all members
google::cloud::v1::PollingPolicy Class Referenceabstract

Control the Cloud C++ client library behavior with respect to polling on long running operations. More...

#include <google/cloud/polling_policy.h>

Public Member Functions

virtual ~PollingPolicy ()=default
 
virtual std::unique_ptr< PollingPolicyclone () const =0
 Return a copy of the current policy. More...
 
virtual bool OnFailure (google::cloud::Status const &status)=0
 A callback to indicate that a polling attempt failed. More...
 
virtual std::chrono::milliseconds WaitPeriod ()=0
 How long should the polling loop wait before trying again. More...
 

Detailed Description

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.

See also
https://aip.dev/151 for more information on long running operations.

Definition at line 46 of file polling_policy.h.

Constructor & Destructor Documentation

◆ ~PollingPolicy()

virtual google::cloud::v1::PollingPolicy::~PollingPolicy ( )
virtualdefault

Member Function Documentation

◆ clone()

virtual std::unique_ptr<PollingPolicy> google::cloud::v1::PollingPolicy::clone ( ) const
pure virtual

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.

Implemented in google::cloud::v1::GenericPollingPolicy< Retry, Backoff >.

◆ OnFailure()

virtual bool google::cloud::v1::PollingPolicy::OnFailure ( google::cloud::Status const &  status)
pure virtual

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.

Implemented in google::cloud::v1::GenericPollingPolicy< Retry, Backoff >.

◆ WaitPeriod()

virtual std::chrono::milliseconds google::cloud::v1::PollingPolicy::WaitPeriod ( )
pure virtual

How long should the polling loop wait before trying again.

Implemented in google::cloud::v1::GenericPollingPolicy< Retry, Backoff >.