Library reference docs
Namespaces
google::cloud
Classes
Structs
Functions
google::cloud::mocks
Stay organized with collections Save and categorize content based on your preferences.
While the client libraries defaults should work for most applications, there are multiple runtime configuration options that applications may need to set. For example, the application may need to override the endpoint used to access the service, or change the retry policies to be more strict (or lenient) than the defaults.
Applications use google::cloud::Options
to override the defaults. You can think of an instance of google::cloud::Options
as a set of overrides, indexed by a C++ type that uniquely identifies the option. There is no need for applications to fill this set with the defaults.
For most libraries overrides can be made at 3 different levels:
*Client
objects*Connection
objectsIn general, function call overrides take precedence over *Client
overrides, and these in turn take precedence over any overrides in the *Connection
override. However, most options can only be set when the *Connection
object is created. You need to consult the documentation for an option to determine if they are usable for a specific function call.
Consider this example:
#include "google/cloud/kms/key_management_client.h"
#include "google/cloud/kms/key_management_connection.h"
#include "google/cloud/kms/key_management_options.h"
#include "google/cloud/common_options.h"
using kms = ::google::cloud::kms;
using g = ::google::cloud;
// `parent` must be in the form "projects/<project-id>/locations/<region-id>".
// For example F("projects/my-project/locations/us-central1")
void F(std::string const& parent) {
auto retry = [](int n) { return kms::LimitedErrorCountRetryPolicy(n).clone(); };
auto conn_1 = kms::MakeKeyManagementServiceConnection();
auto conn_2 = kms::MakeKeyManagementServiceConnection(
g::Options{}
.set<g::EndpointOption>("private.googleapis.com")
.set<kms::KeyManagementServiceRetryPolicyOption>(retry(3)));
auto client_1 = kms::KeyManagementServiceClient(conn_1);
auto client_2 = kms::KeyManagementServiceClient(conn_2);
auto client_3 = kms::KeyManagementServiceClient(conn_2, g::Options{}
.set<kms::KeyManagementServiceRetryPolicyOption>(retry(5));
auto rpc_1 = client_1.ListKeyRings(parent);
auto rpc_2 = client_2.ListKeyRings(parent);
auto rpc_3 = client_3.ListKeyRings(parent);
auto rpc_4 = client_3.ListKeyRights(parent,
g::Options{}.set<kms::KeyManagementServiceRetryPolicyOption>(retry(7)));
}
In this case, rpc_4
will retry the request up to 7 times, because the value of the kms::RetryPolicyOption
overrides the values at the connection or client level. Meanwhile, rpc_3
will retry the request 5 times, because the value at the *Client
level overrides the value at the *Connection
level. Likewise, rpc_2
will retry the request 3 times, because this is the value in the *Connection
and there are no overrides in the client or function calls. Finally, rpc_1
will use the default. For this service the default is to retry for 30 minutes.
Note that only the connection overrides the g::EndpointOption
. Overriding this option at the *Client
or function call level would have no effect.
All libraries have options that are only meaningful for that library (and ignored by other libraries). In some cases, the option may be specific to a service* (sometimes called "an API"). In the previous example, the kms::KeyManagementServiceRetryPolicyOption
is only applicable to kms::KeyManagementServiceClient
and kms::KeyManagementServiceConnection
. Other services in the same library (e.g., kms::EkmServiceClient
) will ignore this option. Likewise, other services in different libraries (e.g. pubsub::Publisher
) will also ignore the option.
google::cloud::EndpointOption
google::cloud::UserAgentProductsOption
google::cloud::UserProjectOption
google::cloud::AuthorityOption
google::cloud::ProxyOption
google::cloud::UnifiedCredentialsOption
google::cloud::DelegatesOption
google::cloud::ScopesOption
google::cloud::AccessTokenLifetimeOption
google::cloud::CARootsFilePathOption
google::cloud::GrpcCredentialOption
google::cloud::GrpcCompressionAlgorithmOption
google::cloud::GrpcNumChannelsOption
google::cloud::GrpcChannelArgumentsOption
google::cloud::GrpcChannelArgumentsNativeOption
google::cloud::GrpcTracingOptionsOption
google::cloud::GrpcBackgroundThreadPoolSizeOption
google::cloud::GrpcCompletionQueueOption
google::cloud::GrpcBackgroundThreadsFactoryOption
google::cloud::OpenTelemetryTracingOption
google::cloud::Options
google::cloud::RestTracingOptionsOption
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 details the configuration options for Google Cloud Client Libraries, explaining how to override default settings for service access and retry policies."],["Overrides to default configurations can be made at three levels: function calls, `*Client` objects, and `*Connection` objects, with function call overrides taking the highest precedence."],["Applications use `google::cloud::Options` to modify the default configurations, using a C++ type to uniquely identify each option to override it."],["Libraries can have unique options specific to their service, such as `kms::KeyManagementServiceRetryPolicyOption`, which are only applicable to that library or service."],["The document lists a variety of option classes available for configuration, covering areas such as credentials, endpoints, proxies, and gRPC settings."]]],[]]
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