A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cloud.google.com/cpp/docs/reference/common/2.35.0/group__options below:

Client Library Configuration (2.35.0) | C++ Client Libraries

Skip to main content Client Library Configuration (2.35.0)

Stay organized with collections Save and categorize content based on your preferences.

Client Library Configuration Overview

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.

Override Priority

For most libraries overrides can be made at 3 different levels:

In 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.

Library-specific Options

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.

Classes Types

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."],[[["The webpage provides documentation for various versions of a C++ client library, ranging from version 2.10.1 to the latest release candidate 2.37.0-rc."],["Client libraries allow users to override default configurations using `google::cloud::Options`, with the ability to set overrides at the function call, `*Client`, and `*Connection` levels."],["Configuration overrides have a priority order, where function call overrides take precedence over `*Client` overrides, which in turn override `*Connection` settings, offering flexible customization."],["Certain options, such as `kms::KeyManagementServiceRetryPolicyOption`, are specific to individual services or libraries, and will be ignored if used for a different service."],["The page lists numerous available classes for configuration, such as `google::cloud::EndpointOption`, `google::cloud::GrpcNumChannelsOption`, and `google::cloud::OpenTelemetryTracingOption`, offering a wide range of customization options."]]],[]]


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