Showing content from http://cloud.google.com/cpp/docs/reference/storage/2.16.0/storage-retry-examples below:
C++ Client Libraries | Google Cloud
Skip to main content
- Overview
-
Library reference docs
- Google Cloud Storage C++ Client Library
-
Namespaces
-
google::cloud::storage
- Overview
-
Classes
-
Functions
- PublicAccessPreventionEnforced()
- PublicAccessPreventionInherited()
- PublicAccessPreventionUnspecified()
- TEAM_EDITORS()
- TEAM_OWNERS()
- TEAM_VIEWERS()
- AutoFinalizeEnabled()
- AutoFinalizeDisabled()
- RpoDefault()
- RpoAsyncTurbo()
- CreateRandomPrefixName(std::string const &)
- DeleteByPrefix(Client &, std::string const &, std::string const &, Options &&...)
- ComposeMany(Client &, std::string const &, std::vector< ComposeSourceObject >, std::string const &, std::string, bool, Options &&...)
- ComputeMD5Hash(absl::string_view)
- ComputeMD5Hash(std::string const &)
- ComputeMD5Hash(char const *)
- EnableMD5Hash()
- ComputeCrc32cChecksum(absl::string_view)
- ComputeCrc32cChecksum(std::string const &)
- ComputeCrc32cChecksum(char const *)
- ParallelUploadFile(Client, std::string, std::string, std::string, std::string, bool, Options &&...)
- FormatDateForForm(PolicyDocumentV4Result const &)
- AddExtensionHeader(std::string, std::string)
- WithGeneration(std::uint64_t)
- WithGenerationMarker(std::uint64_t)
- WithUserProject(std::string)
- WithMarker(std::string)
- WithResponseContentDisposition(std::string)
- WithResponseContentType(std::string const &)
- WithAcl()
- WithBilling()
- WithCompose()
- WithCors()
- WithEncryption()
- WithEncryptionConfig()
- WithLifecycle()
- WithLocation()
- WithLogging()
- WithStorageClass()
- WithTagging()
- AddExtensionField(std::string, std::string)
- RestoreResumableUploadSession(std::string)
- NewResumableUploadSession()
- version_major()
- version_minor()
- version_patch()
- version_pre_release()
- version()
- version_string()
- x_goog_api_client()
- EncryptionDataFromBinaryKey(std::string const &)
- EncryptionDataFromBase64Key(std::string const &)
- CreateKeyFromGenerator(Generator &)
- AcceptEncodingGzip()
- AcceptEncodingIdentity()
-
Operators
- operator==(CorsEntry const &, CorsEntry const &)
- operator<(CorsEntry const &, CorsEntry const &)
- operator!=(CorsEntry const &, CorsEntry const &)
- operator>(CorsEntry const &, CorsEntry const &)
- operator<=(CorsEntry const &, CorsEntry const &)
- operator>=(CorsEntry const &, CorsEntry const &)
- operator==(BucketCustomPlacementConfig const &, BucketCustomPlacementConfig const &)
- operator<(BucketCustomPlacementConfig const &, BucketCustomPlacementConfig const &)
- operator!=(BucketCustomPlacementConfig const &, BucketCustomPlacementConfig const &)
- operator>(BucketCustomPlacementConfig const &, BucketCustomPlacementConfig const &)
- operator<=(BucketCustomPlacementConfig const &, BucketCustomPlacementConfig const &)
- operator>=(BucketCustomPlacementConfig const &, BucketCustomPlacementConfig const &)
- operator==(UniformBucketLevelAccess const &, UniformBucketLevelAccess const &)
- operator<(UniformBucketLevelAccess const &, UniformBucketLevelAccess const &)
- operator!=(UniformBucketLevelAccess const &, UniformBucketLevelAccess const &)
- operator>(UniformBucketLevelAccess const &, UniformBucketLevelAccess const &)
- operator<=(UniformBucketLevelAccess const &, UniformBucketLevelAccess const &)
- operator>=(UniformBucketLevelAccess const &, UniformBucketLevelAccess const &)
- operator==(BucketIamConfiguration const &, BucketIamConfiguration const &)
- operator<(BucketIamConfiguration const &, BucketIamConfiguration const &)
- operator!=(BucketIamConfiguration const &, BucketIamConfiguration const &)
- operator>(BucketIamConfiguration const &, BucketIamConfiguration const &)
- operator<=(BucketIamConfiguration const &, BucketIamConfiguration const &)
- operator>=(BucketIamConfiguration const &, BucketIamConfiguration const &)
- operator==(BucketLifecycle const &, BucketLifecycle const &)
- operator<(BucketLifecycle const &, BucketLifecycle const &)
- operator!=(BucketLifecycle const &, BucketLifecycle const &)
- operator>(BucketLifecycle const &, BucketLifecycle const &)
- operator<=(BucketLifecycle const &, BucketLifecycle const &)
- operator>=(BucketLifecycle const &, BucketLifecycle const &)
- operator<<(std::ostream &, AutoFinalize const &)
- operator<<(std::ostream &, BucketAccessControl const &)
- operator==(BucketAutoclass const &, BucketAutoclass const &)
- operator!=(BucketAutoclass const &, BucketAutoclass const &)
- operator<<(std::ostream &, BucketAutoclass const &)
- operator==(BucketBilling const &, BucketBilling const &)
- operator<(BucketBilling const &, BucketBilling const &)
- operator!=(BucketBilling const &, BucketBilling const &)
- operator>(BucketBilling const &, BucketBilling const &)
- operator<=(BucketBilling const &, BucketBilling const &)
- operator>=(BucketBilling const &, BucketBilling const &)
- operator<<(std::ostream &, CorsEntry const &)
- operator<<(std::ostream &, BucketCustomPlacementConfig const &)
- operator==(BucketEncryption const &, BucketEncryption const &)
- operator<(BucketEncryption const &, BucketEncryption const &)
- operator!=(BucketEncryption const &, BucketEncryption const &)
- operator>(BucketEncryption const &, BucketEncryption const &)
- operator<=(BucketEncryption const &, BucketEncryption const &)
- operator>=(BucketEncryption const &, BucketEncryption const &)
- operator<<(std::ostream &, UniformBucketLevelAccess const &)
- operator<<(std::ostream &, BucketIamConfiguration const &)
- operator==(BucketLogging const &, BucketLogging const &)
- operator<(BucketLogging const &, BucketLogging const &)
- operator!=(BucketLogging const &, BucketLogging const &)
- operator>(BucketLogging const &, BucketLogging const &)
- operator<=(BucketLogging const &, BucketLogging const &)
- operator>=(BucketLogging const &, BucketLogging const &)
- operator<<(std::ostream &, BucketLogging const &)
- operator<<(std::ostream &, BucketMetadata const &)
- operator==(BucketRetentionPolicy const &, BucketRetentionPolicy const &)
- operator<(BucketRetentionPolicy const &, BucketRetentionPolicy const &)
- operator!=(BucketRetentionPolicy const &, BucketRetentionPolicy const &)
- operator>(BucketRetentionPolicy const &, BucketRetentionPolicy const &)
- operator<=(BucketRetentionPolicy const &, BucketRetentionPolicy const &)
- operator>=(BucketRetentionPolicy const &, BucketRetentionPolicy const &)
- operator<<(std::ostream &, BucketRetentionPolicy const &)
- operator==(BucketVersioning const &, BucketVersioning const &)
- operator<(BucketVersioning const &, BucketVersioning const &)
- operator!=(BucketVersioning const &, BucketVersioning const &)
- operator>(BucketVersioning const &, BucketVersioning const &)
- operator<=(BucketVersioning const &, BucketVersioning const &)
- operator>=(BucketVersioning const &, BucketVersioning const &)
- operator==(BucketWebsite const &, BucketWebsite const &)
- operator<(BucketWebsite const &, BucketWebsite const &)
- operator!=(BucketWebsite const &, BucketWebsite const &)
- operator>(BucketWebsite const &, BucketWebsite const &)
- operator<=(BucketWebsite const &, BucketWebsite const &)
- operator>=(BucketWebsite const &, BucketWebsite const &)
- operator<<(std::ostream &, ReadRangeData const &)
- operator==(HmacKeyMetadata const &, HmacKeyMetadata const &)
- operator!=(HmacKeyMetadata const &, HmacKeyMetadata const &)
- operator<<(std::ostream &, HmacKeyMetadata const &)
- operator<<(std::ostream &, NativeExpression const &)
- operator<<(std::ostream &, NativeIamBinding const &)
- operator<<(std::ostream &, NativeIamPolicy const &)
- operator==(LifecycleRuleAction const &, LifecycleRuleAction const &)
- operator<(LifecycleRuleAction const &, LifecycleRuleAction const &)
- operator!=(LifecycleRuleAction const &, LifecycleRuleAction const &)
- operator>(LifecycleRuleAction const &, LifecycleRuleAction const &)
- operator<=(LifecycleRuleAction const &, LifecycleRuleAction const &)
- operator>=(LifecycleRuleAction const &, LifecycleRuleAction const &)
- operator<<(std::ostream &, LifecycleRuleAction const &)
- operator==(LifecycleRuleCondition const &, LifecycleRuleCondition const &)
- operator<(LifecycleRuleCondition const &, LifecycleRuleCondition const &)
- operator!=(LifecycleRuleCondition const &, LifecycleRuleCondition const &)
- operator>(LifecycleRuleCondition const &, LifecycleRuleCondition const &)
- operator<=(LifecycleRuleCondition const &, LifecycleRuleCondition const &)
- operator>=(LifecycleRuleCondition const &, LifecycleRuleCondition const &)
- operator<<(std::ostream &, LifecycleRuleCondition const &)
- operator==(LifecycleRule const &, LifecycleRule const &)
- operator<(LifecycleRule const &, LifecycleRule const &)
- operator!=(LifecycleRule const &, LifecycleRule const &)
- operator>(LifecycleRule const &, LifecycleRule const &)
- operator<=(LifecycleRule const &, LifecycleRule const &)
- operator>=(LifecycleRule const &, LifecycleRule const &)
- operator<<(std::ostream &, LifecycleRule const &)
- operator==(NotificationMetadata const &, NotificationMetadata const &)
- operator<(NotificationMetadata const &, NotificationMetadata const &)
- operator!=(NotificationMetadata const &, NotificationMetadata const &)
- operator>(NotificationMetadata const &, NotificationMetadata const &)
- operator<=(NotificationMetadata const &, NotificationMetadata const &)
- operator>=(NotificationMetadata const &, NotificationMetadata const &)
- operator<<(std::ostream &, NotificationMetadata const &)
- operator<<(std::ostream &, ObjectAccessControl const &)
- operator<<(std::ostream &, ComposeSourceObject const &)
- operator==(CustomerEncryption const &, CustomerEncryption const &)
- operator<(CustomerEncryption const &, CustomerEncryption const &)
- operator!=(CustomerEncryption const &, CustomerEncryption const &)
- operator>(CustomerEncryption const &, CustomerEncryption const &)
- operator<=(CustomerEncryption const &, CustomerEncryption const &)
- operator>=(CustomerEncryption const &, CustomerEncryption const &)
- operator<<(std::ostream &, ObjectMetadata const &)
- operator==(Owner const &, Owner const &)
- operator<(Owner const &, Owner const &)
- operator!=(Owner const &, Owner const &)
- operator>(Owner const &, Owner const &)
- operator<=(Owner const &, Owner const &)
- operator>=(Owner const &, Owner const &)
- operator==(PolicyDocumentCondition const &, PolicyDocumentCondition const &)
- operator<(PolicyDocumentCondition const &, PolicyDocumentCondition const &)
- operator!=(PolicyDocumentCondition const &, PolicyDocumentCondition const &)
- operator>(PolicyDocumentCondition const &, PolicyDocumentCondition const &)
- operator<=(PolicyDocumentCondition const &, PolicyDocumentCondition const &)
- operator>=(PolicyDocumentCondition const &, PolicyDocumentCondition const &)
- operator<<(std::ostream &, PolicyDocumentCondition const &)
- operator<<(std::ostream &, PolicyDocument const &)
- operator<<(std::ostream &, PolicyDocumentV4 const &)
- operator<<(std::ostream &, PolicyDocumentResult const &)
- operator<<(std::ostream &, PolicyDocumentV4Result const &)
- operator==(ProjectTeam const &, ProjectTeam const &)
- operator<(ProjectTeam const &, ProjectTeam const &)
- operator!=(ProjectTeam const &, ProjectTeam const &)
- operator>(ProjectTeam const &, ProjectTeam const &)
- operator<=(ProjectTeam const &, ProjectTeam const &)
- operator>=(ProjectTeam const &, ProjectTeam const &)
- operator==(ServiceAccount const &, ServiceAccount const &)
- operator<(ServiceAccount const &, ServiceAccount const &)
- operator!=(ServiceAccount const &, ServiceAccount const &)
- operator>(ServiceAccount const &, ServiceAccount const &)
- operator<=(ServiceAccount const &, ServiceAccount const &)
- operator>=(ServiceAccount const &, ServiceAccount const &)
- operator<<(std::ostream &, ServiceAccount const &)
- operator<<(std::ostream &, CustomHeader const &)
- operator<<(std::ostream &, EncryptionKey const &)
- operator<<(std::ostream &, SourceEncryptionKey const &)
-
google::cloud::storage::event_type
-
google::cloud::storage::oauth2
- Overview
-
Classes
-
AuthorizedUserCredentials<HttpRequestBuilderType, ClockType>
-
ComputeEngineCredentials<HttpRequestBuilderType, ClockType>
-
ServiceAccountCredentials<HttpRequestBuilderType, ClockType>
-
Functions
- CreateAnonymousCredentials()
- CreateAuthorizedUserCredentialsFromJsonFilePath(std::string const &)
- CreateAuthorizedUserCredentialsFromJsonContents(std::string const &, ChannelOptions const &)
- CreateServiceAccountCredentialsFromFilePath(std::string const &)
- CreateServiceAccountCredentialsFromFilePath(std::string const &, absl::optional< std::set< std::string > >, absl::optional< std::string >)
- CreateServiceAccountCredentialsFromJsonFilePath(std::string const &)
- CreateServiceAccountCredentialsFromJsonFilePath(std::string const &, absl::optional< std::set< std::string > >, absl::optional< std::string >, ChannelOptions const &)
- CreateServiceAccountCredentialsFromP12FilePath(std::string const &)
- CreateServiceAccountCredentialsFromP12FilePath(std::string const &, absl::optional< std::set< std::string > >, absl::optional< std::string >, ChannelOptions const &)
- ParseAuthorizedUserRefreshResponse(storage::internal::HttpResponse const &, std::chrono::system_clock::time_point)
- ParseAuthorizedUserCredentials(std::string const &, std::string const &, std::string const &)
- ParseMetadataServerResponse(storage::internal::HttpResponse const &)
- ParseComputeEngineRefreshResponse(storage::internal::HttpResponse const &, std::chrono::system_clock::time_point)
- GoogleOAuthAccessTokenLifetime()
- GoogleOAuthAccessTokenExpirationSlack()
- GoogleOAuthRefreshEndpoint()
- GoogleOAuthScopeCloudPlatform()
- GoogleAdcEnvVar()
- GoogleAdcFilePathFromEnvVarOrEmpty()
- GoogleAdcFilePathFromWellKnownPathOrEmpty()
- GoogleGcloudAdcFileEnvVar()
- GoogleAdcHomeEnvVar()
- GoogleDefaultCredentials(ChannelOptions const &)
- CreateServiceAccountCredentialsFromDefaultPaths(ChannelOptions const &)
- CreateServiceAccountCredentialsFromDefaultPaths(absl::optional< std::set< std::string > >, absl::optional< std::string >, ChannelOptions const &)
- CreateServiceAccountCredentialsFromJsonContents(std::string const &, ChannelOptions const &)
- CreateServiceAccountCredentialsFromJsonContents(std::string const &, absl::optional< std::set< std::string > >, absl::optional< std::string >, ChannelOptions const &)
- CreateComputeEngineCredentials()
- CreateComputeEngineCredentials(std::string const &)
- ParseServiceAccountCredentials(std::string const &, std::string const &, std::string const &)
- ParseServiceAccountP12File(std::string const &, std::string const &)
- ParseServiceAccountRefreshResponse(storage::internal::HttpResponse const &, std::chrono::system_clock::time_point)
- AssertionComponentsFromInfo(ServiceAccountCredentialsInfo const &, std::chrono::system_clock::time_point)
- MakeJWTAssertion(std::string const &, std::string const &, std::string const &)
- CreateServiceAccountRefreshPayload(ServiceAccountCredentialsInfo const &, std::string const &, std::chrono::system_clock::time_point)
- MakeSelfSignedJWT(ServiceAccountCredentialsInfo const &, std::chrono::system_clock::time_point)
- ServiceAccountUseOAuth(ServiceAccountCredentialsInfo const &)
-
google::cloud::storage::payload_format
-
google::cloud::storage::storage_class
-
google::cloud::storage_experimental
- Overview
-
Classes
-
AsyncClient
- Overview
-
Functions
- InsertObject(std::string, std::string, Collection &&, Args &&...)
- ReadObject(std::string, std::string, Args &&...)
- ReadObjectRange(std::string, std::string, std::int64_t, std::int64_t, Args &&...)
- ComposeObject(std::string, std::vector< storage::ComposeSourceObject >, std::string, Args &&...)
- DeleteObject(std::string, std::string, Args &&...)
Stay organized with collections Save and categorize content based on your preferences.
Override the default retry policies
Application developers can override the default retry and backoff policies:
namespace gcs = ::google::cloud::storage;
using ::google::cloud::StatusOr;
[](std::string const& bucket_name, std::string const& object_name,
std::string const& contents) {
// Create a client that only gives up on the third error. The default policy
// is to retry for several minutes.
auto client =
gcs::Client(google::cloud::Options{}.set<gcs::RetryPolicyOption>(
gcs::LimitedErrorCountRetryPolicy(3).clone()));
StatusOr<gcs::ObjectMetadata> object_metadata =
client.InsertObject(bucket_name, object_name, std::move(contents),
gcs::IfGenerationMatch(0));
if (!object_metadata) throw std::move(object_metadata).status();
std::cout << "The object " << object_metadata->name()
<< " was created in bucket " << object_metadata->bucket()
<< "\nFull metadata: " << *object_metadata << "\n";
}
The default policies are to continue retrying for up to 15 minutes, and to use truncated (at 5 minutes) exponential backoff, doubling the maximum backoff period between retries.
By default the library retries all operations, even those that are not idempotent. Application developers can override the idempotency policy to follow a more conservative approach:
namespace gcs = ::google::cloud::storage;
using ::google::cloud::StatusOr;
[](std::string const& bucket_name, std::string const& object_name,
std::string const& contents) {
// Create a client that only retries idempotent operations, the default is
// to retry all operations.
auto client =
gcs::Client(google::cloud::Options{}.set<gcs::IdempotencyPolicyOption>(
gcs::StrictIdempotencyPolicy().clone()));
StatusOr<gcs::ObjectMetadata> object_metadata =
client.InsertObject(bucket_name, object_name, std::move(contents),
gcs::IfGenerationMatch(0));
if (!object_metadata) throw std::move(object_metadata).status();
std::cout << "The object " << object_metadata->name()
<< " was created in bucket " << object_metadata->bucket()
<< "\nFull metadata: " << *object_metadata << "\n";
}
See Also
LimitedTimeRetryPolicy and LimitedErrorCountRetryPolicy for alternative retry policies.
See Also
ExponentialBackoffPolicy to configure different parameters for the exponential backoff policy.
See Also
AlwaysRetryIdempotencyPolicy and StrictIdempotencyPolicy for alternative idempotency policies.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-14 UTC.
[[["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-08-14 UTC."],[[["This document provides access to various versions of storage retry examples, ranging from version 2.11.0 up to the latest release candidate, 2.37.0-rc."],["Developers can customize the default retry and backoff policies, which are set to retry for up to 15 minutes with exponential backoff, by implementing their own policies."],["The default setting retries all operations, but developers have the option to adjust the idempotency policy to retry only idempotent operations."],["Alternative retry policies, such as `LimitedTimeRetryPolicy` and `LimitedErrorCountRetryPolicy`, and idempotency policies, such as `AlwaysRetryIdempotencyPolicy` and `StrictIdempotencyPolicy`, are available for use."],["Developers can access documentation for the `ExponentialBackoffPolicy` to configure different parameters for the exponential backoff policy."]]],[]]
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4