This shows how to override the retry policies for channel_v1::CloudChannelReportsServiceClient:
auto options =
google::cloud::Options{}
.set<google::cloud::channel_v1::
CloudChannelReportsServiceConnectionIdempotencyPolicyOption>(
CustomIdempotencyPolicy().clone())
.set<google::cloud::channel_v1::
CloudChannelReportsServiceRetryPolicyOption>(
google::cloud::channel_v1::
CloudChannelReportsServiceLimitedErrorCountRetryPolicy(3)
.clone())
.set<google::cloud::channel_v1::
CloudChannelReportsServiceBackoffPolicyOption>(
google::cloud::ExponentialBackoffPolicy(
/*initial_delay=*/std::chrono::milliseconds(200),
/*maximum_delay=*/std::chrono::seconds(45),
/*scaling=*/2.0)
.clone());
auto connection =
google::cloud::channel_v1::MakeCloudChannelReportsServiceConnection(
options);
// c1 and c2 share the same retry policies
auto c1 =
google::cloud::channel_v1::CloudChannelReportsServiceClient(connection);
auto c2 =
google::cloud::channel_v1::CloudChannelReportsServiceClient(connection);
// You can override any of the policies in a new client. This new client
// will share the policies from c1 (or c2) *except* for the retry policy.
auto c3 = google::cloud::channel_v1::CloudChannelReportsServiceClient(
connection, google::cloud::Options{}
.set<google::cloud::channel_v1::
CloudChannelReportsServiceRetryPolicyOption>(
google::cloud::channel_v1::
CloudChannelReportsServiceLimitedTimeRetryPolicy(
std::chrono::minutes(5))
.clone()));
// You can also override the policies in a single call:
// c3.SomeRpc(..., google::cloud::Options{}
// .set<google::cloud::channel_v1::CloudChannelReportsServiceRetryPolicyOption>(
// google::cloud::channel_v1::CloudChannelReportsServiceLimitedErrorCountRetryPolicy(10).clone()));
Assuming you have created a custom idempotency policy. Such as:
class CustomIdempotencyPolicy
: public google::cloud::channel_v1::
CloudChannelReportsServiceConnectionIdempotencyPolicy {
public:
~CustomIdempotencyPolicy() override = default;
std::unique_ptr<google::cloud::channel_v1::
CloudChannelReportsServiceConnectionIdempotencyPolicy>
clone() const override {
return std::make_unique<CustomIdempotencyPolicy>(*this);
}
// Override inherited functions to define as needed.
};
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[[["\u003cp\u003eThe latest version available is 2.37.0-rc, with numerous other versions accessible from 2.36.0 down to 2.11.0, each with their respective documentation.\u003c/p\u003e\n"],["\u003cp\u003eThis documentation provides instructions on how to override retry policies for \u003ccode\u003echannel_v1::CloudChannelReportsServiceClient\u003c/code\u003e, allowing for custom configurations.\u003c/p\u003e\n"],["\u003cp\u003eThe provided code examples demonstrate how to set custom retry policies, including options for error count and time limits, and create multiple clients that can share or have unique retry configurations.\u003c/p\u003e\n"],["\u003cp\u003eUsers can define a \u003ccode\u003eCustomIdempotencyPolicy\u003c/code\u003e class to customize the idempotency behavior, overriding inherited functions as necessary.\u003c/p\u003e\n"],["\u003cp\u003eIt is also possible to change retry policies for specific calls, without needing to change it for the client as a whole.\u003c/p\u003e\n"]]],[],null,["Version 2.31.0keyboard_arrow_down\n\n- [2.42.0-rc (latest)](/cpp/docs/reference/channel/latest/channel_v1_1_1CloudChannelReportsServiceClient-retry-snippet)\n- [2.41.0](/cpp/docs/reference/channel/2.41.0/channel_v1_1_1CloudChannelReportsServiceClient-retry-snippet)\n- [2.40.0](/cpp/docs/reference/channel/2.40.0/channel_v1_1_1CloudChannelReportsServiceClient-retry-snippet)\n- [2.39.0](/cpp/docs/reference/channel/2.39.0/channel_v1_1_1CloudChannelReportsServiceClient-retry-snippet)\n- [2.38.0](/cpp/docs/reference/channel/2.38.0/channel_v1_1_1CloudChannelReportsServiceClient-retry-snippet)\n- [2.37.0](/cpp/docs/reference/channel/2.37.0/channel_v1_1_1CloudChannelReportsServiceClient-retry-snippet)\n- [2.36.0](/cpp/docs/reference/channel/2.36.0/channel_v1_1_1CloudChannelReportsServiceClient-retry-snippet)\n- [2.35.0](/cpp/docs/reference/channel/2.35.0/channel_v1_1_1CloudChannelReportsServiceClient-retry-snippet)\n- [2.34.0](/cpp/docs/reference/channel/2.34.0/channel_v1_1_1CloudChannelReportsServiceClient-retry-snippet)\n- [2.33.0](/cpp/docs/reference/channel/2.33.0/channel_v1_1_1CloudChannelReportsServiceClient-retry-snippet)\n- [2.32.0](/cpp/docs/reference/channel/2.32.0/channel_v1_1_1CloudChannelReportsServiceClient-retry-snippet)\n- [2.31.0](/cpp/docs/reference/channel/2.31.0/channel_v1_1_1CloudChannelReportsServiceClient-retry-snippet)\n- [2.30.0](/cpp/docs/reference/channel/2.30.0/channel_v1_1_1CloudChannelReportsServiceClient-retry-snippet)\n- [2.29.0](/cpp/docs/reference/channel/2.29.0/channel_v1_1_1CloudChannelReportsServiceClient-retry-snippet)\n- [2.28.0](/cpp/docs/reference/channel/2.28.0/channel_v1_1_1CloudChannelReportsServiceClient-retry-snippet)\n- [2.27.0](/cpp/docs/reference/channel/2.27.0/channel_v1_1_1CloudChannelReportsServiceClient-retry-snippet)\n- [2.26.0](/cpp/docs/reference/channel/2.26.0/channel_v1_1_1CloudChannelReportsServiceClient-retry-snippet)\n- [2.25.1](/cpp/docs/reference/channel/2.25.1/channel_v1_1_1CloudChannelReportsServiceClient-retry-snippet)\n- [2.24.0](/cpp/docs/reference/channel/2.24.0/channel_v1_1_1CloudChannelReportsServiceClient-retry-snippet)\n- [2.23.0](/cpp/docs/reference/channel/2.23.0/channel_v1_1_1CloudChannelReportsServiceClient-retry-snippet)\n- [2.22.1](/cpp/docs/reference/channel/2.22.1/channel_v1_1_1CloudChannelReportsServiceClient-retry-snippet)\n- [2.21.0](/cpp/docs/reference/channel/2.21.0/channel_v1_1_1CloudChannelReportsServiceClient-retry-snippet)\n- [2.20.0](/cpp/docs/reference/channel/2.20.0/channel_v1_1_1CloudChannelReportsServiceClient-retry-snippet)\n- [2.19.0](/cpp/docs/reference/channel/2.19.0/channel_v1_1_1CloudChannelReportsServiceClient-retry-snippet)\n- [2.18.0](/cpp/docs/reference/channel/2.18.0/channel_v1_1_1CloudChannelReportsServiceClient-retry-snippet)\n- [2.17.0](/cpp/docs/reference/channel/2.17.0/channel_v1_1_1CloudChannelReportsServiceClient-retry-snippet)\n- [2.16.0](/cpp/docs/reference/channel/2.16.0/channel_v1_1_1CloudChannelReportsServiceClient-retry-snippet)\n- [2.15.1](/cpp/docs/reference/channel/2.15.1/channel_v1_1_1CloudChannelReportsServiceClient-retry-snippet)\n- [2.14.0](/cpp/docs/reference/channel/2.14.0/channel_v1_1_1CloudChannelReportsServiceClient-retry-snippet)\n- [2.13.0](/cpp/docs/reference/channel/2.13.0/channel_v1_1_1CloudChannelReportsServiceClient-retry-snippet)\n- [2.12.0](/cpp/docs/reference/channel/2.12.0/channel_v1_1_1CloudChannelReportsServiceClient-retry-snippet)\n- [2.11.0](/cpp/docs/reference/channel/2.11.0/channel_v1_1_1CloudChannelReportsServiceClient-retry-snippet) \n\nOverride channel_v1::CloudChannelReportsServiceClient Retry Policies\n====================================================================\n\nThis shows how to override the retry policies for channel_v1::CloudChannelReportsServiceClient: \n\n auto options =\n google::cloud::Options{}\n .set\u003cgoogle::cloud::channel_v1::\n CloudChannelReportsServiceConnectionIdempotencyPolicyOption\u003e(\n CustomIdempotencyPolicy().clone())\n .set\u003cgoogle::cloud::channel_v1::\n CloudChannelReportsServiceRetryPolicyOption\u003e(\n google::cloud::channel_v1::\n CloudChannelReportsServiceLimitedErrorCountRetryPolicy(3)\n .clone())\n .set\u003cgoogle::cloud::channel_v1::\n CloudChannelReportsServiceBackoffPolicyOption\u003e(\n google::cloud::ExponentialBackoffPolicy(\n /*initial_delay=*/std::chrono::milliseconds(200),\n /*maximum_delay=*/std::chrono::seconds(45),\n /*scaling=*/2.0)\n .clone());\n auto connection =\n google::cloud::channel_v1::MakeCloudChannelReportsServiceConnection(\n options);\n\n // c1 and c2 share the same retry policies\n auto c1 =\n google::cloud::channel_v1::CloudChannelReportsServiceClient(connection);\n auto c2 =\n google::cloud::channel_v1::CloudChannelReportsServiceClient(connection);\n\n // You can override any of the policies in a new client. This new client\n // will share the policies from c1 (or c2) *except* for the retry policy.\n auto c3 = google::cloud::channel_v1::CloudChannelReportsServiceClient(\n connection, google::cloud::Options{}\n .set\u003cgoogle::cloud::channel_v1::\n CloudChannelReportsServiceRetryPolicyOption\u003e(\n google::cloud::channel_v1::\n CloudChannelReportsServiceLimitedTimeRetryPolicy(\n std::chrono::minutes(5))\n .clone()));\n\n // You can also override the policies in a single call:\n // c3.SomeRpc(..., google::cloud::Options{}\n // .set\u003cgoogle::cloud::channel_v1::CloudChannelReportsServiceRetryPolicyOption\u003e(\n // google::cloud::channel_v1::CloudChannelReportsServiceLimitedErrorCountRetryPolicy(10).clone()));\n\nAssuming you have created a custom idempotency policy. Such as: \n\n class CustomIdempotencyPolicy\n : public google::cloud::channel_v1::\n CloudChannelReportsServiceConnectionIdempotencyPolicy {\n public:\n ~CustomIdempotencyPolicy() override = default;\n std::unique_ptr\u003cgoogle::cloud::channel_v1::\n CloudChannelReportsServiceConnectionIdempotencyPolicy\u003e\n clone() const override {\n return std::make_unique\u003cCustomIdempotencyPolicy\u003e(*this);\n }\n // Override inherited functions to define as needed.\n };"]]