This shows how to override the retry policies for talent_v4::JobServiceClient:
auto options =
google::cloud::Options{}
.set<google::cloud::talent_v4::
JobServiceConnectionIdempotencyPolicyOption>(
CustomIdempotencyPolicy().clone())
.set<google::cloud::talent_v4::JobServiceRetryPolicyOption>(
google::cloud::talent_v4::JobServiceLimitedErrorCountRetryPolicy(
3)
.clone())
.set<google::cloud::talent_v4::JobServiceBackoffPolicyOption>(
google::cloud::ExponentialBackoffPolicy(
/*initial_delay=*/std::chrono::milliseconds(200),
/*maximum_delay=*/std::chrono::seconds(45),
/*scaling=*/2.0)
.clone());
auto connection = google::cloud::talent_v4::MakeJobServiceConnection(options);
// c1 and c2 share the same retry policies
auto c1 = google::cloud::talent_v4::JobServiceClient(connection);
auto c2 = google::cloud::talent_v4::JobServiceClient(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::talent_v4::JobServiceClient(
connection,
google::cloud::Options{}
.set<google::cloud::talent_v4::JobServiceRetryPolicyOption>(
google::cloud::talent_v4::JobServiceLimitedTimeRetryPolicy(
std::chrono::minutes(5))
.clone()));
// You can also override the policies in a single call:
// c3.SomeRpc(..., google::cloud::Options{}
// .set<google::cloud::talent_v4::JobServiceRetryPolicyOption>(
// google::cloud::talent_v4::JobServiceLimitedErrorCountRetryPolicy(10).clone()));
Assuming you have created a custom idempotency policy. Such as:
class CustomIdempotencyPolicy
: public google::cloud::talent_v4::JobServiceConnectionIdempotencyPolicy {
public:
~CustomIdempotencyPolicy() override = default;
std::unique_ptr<
google::cloud::talent_v4::JobServiceConnectionIdempotencyPolicy>
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\u003eThis document details how to override retry policies for the \u003ccode\u003etalent_v4::JobServiceClient\u003c/code\u003e, focusing on version 2.21.0 and later versions.\u003c/p\u003e\n"],["\u003cp\u003eThe latest version available is \u003ccode\u003e2.37.0-rc\u003c/code\u003e, with a range of previous versions down to \u003ccode\u003e2.11.0\u003c/code\u003e accessible through provided links.\u003c/p\u003e\n"],["\u003cp\u003eYou can configure custom retry behavior by setting options for \u003ccode\u003eJobServiceConnectionIdempotencyPolicyOption\u003c/code\u003e, \u003ccode\u003eJobServiceRetryPolicyOption\u003c/code\u003e, and \u003ccode\u003eJobServiceBackoffPolicyOption\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eMultiple \u003ccode\u003eJobServiceClient\u003c/code\u003e instances can share the same retry policies, and you can create new clients with modified policies.\u003c/p\u003e\n"],["\u003cp\u003eRetry policies can be overridden on a per-call basis for specific RPCs, allowing for granular control over retries for individual operations.\u003c/p\u003e\n"]]],[],null,["Version 2.21.0keyboard_arrow_down\n\n- [2.42.0-rc (latest)](/cpp/docs/reference/talent/latest/talent_v4_1_1JobServiceClient-retry-snippet)\n- [2.41.0](/cpp/docs/reference/talent/2.41.0/talent_v4_1_1JobServiceClient-retry-snippet)\n- [2.40.0](/cpp/docs/reference/talent/2.40.0/talent_v4_1_1JobServiceClient-retry-snippet)\n- [2.39.0](/cpp/docs/reference/talent/2.39.0/talent_v4_1_1JobServiceClient-retry-snippet)\n- [2.38.0](/cpp/docs/reference/talent/2.38.0/talent_v4_1_1JobServiceClient-retry-snippet)\n- [2.37.0](/cpp/docs/reference/talent/2.37.0/talent_v4_1_1JobServiceClient-retry-snippet)\n- [2.36.0](/cpp/docs/reference/talent/2.36.0/talent_v4_1_1JobServiceClient-retry-snippet)\n- [2.35.0](/cpp/docs/reference/talent/2.35.0/talent_v4_1_1JobServiceClient-retry-snippet)\n- [2.34.0](/cpp/docs/reference/talent/2.34.0/talent_v4_1_1JobServiceClient-retry-snippet)\n- [2.33.0](/cpp/docs/reference/talent/2.33.0/talent_v4_1_1JobServiceClient-retry-snippet)\n- [2.32.0](/cpp/docs/reference/talent/2.32.0/talent_v4_1_1JobServiceClient-retry-snippet)\n- [2.31.0](/cpp/docs/reference/talent/2.31.0/talent_v4_1_1JobServiceClient-retry-snippet)\n- [2.30.0](/cpp/docs/reference/talent/2.30.0/talent_v4_1_1JobServiceClient-retry-snippet)\n- [2.29.0](/cpp/docs/reference/talent/2.29.0/talent_v4_1_1JobServiceClient-retry-snippet)\n- [2.28.0](/cpp/docs/reference/talent/2.28.0/talent_v4_1_1JobServiceClient-retry-snippet)\n- [2.27.0](/cpp/docs/reference/talent/2.27.0/talent_v4_1_1JobServiceClient-retry-snippet)\n- [2.26.0](/cpp/docs/reference/talent/2.26.0/talent_v4_1_1JobServiceClient-retry-snippet)\n- [2.25.1](/cpp/docs/reference/talent/2.25.1/talent_v4_1_1JobServiceClient-retry-snippet)\n- [2.24.0](/cpp/docs/reference/talent/2.24.0/talent_v4_1_1JobServiceClient-retry-snippet)\n- [2.23.0](/cpp/docs/reference/talent/2.23.0/talent_v4_1_1JobServiceClient-retry-snippet)\n- [2.22.1](/cpp/docs/reference/talent/2.22.1/talent_v4_1_1JobServiceClient-retry-snippet)\n- [2.21.0](/cpp/docs/reference/talent/2.21.0/talent_v4_1_1JobServiceClient-retry-snippet)\n- [2.20.0](/cpp/docs/reference/talent/2.20.0/talent_v4_1_1JobServiceClient-retry-snippet)\n- [2.19.0](/cpp/docs/reference/talent/2.19.0/talent_v4_1_1JobServiceClient-retry-snippet)\n- [2.18.0](/cpp/docs/reference/talent/2.18.0/talent_v4_1_1JobServiceClient-retry-snippet)\n- [2.17.0](/cpp/docs/reference/talent/2.17.0/talent_v4_1_1JobServiceClient-retry-snippet)\n- [2.16.0](/cpp/docs/reference/talent/2.16.0/talent_v4_1_1JobServiceClient-retry-snippet)\n- [2.15.1](/cpp/docs/reference/talent/2.15.1/talent_v4_1_1JobServiceClient-retry-snippet)\n- [2.14.0](/cpp/docs/reference/talent/2.14.0/talent_v4_1_1JobServiceClient-retry-snippet)\n- [2.13.0](/cpp/docs/reference/talent/2.13.0/talent_v4_1_1JobServiceClient-retry-snippet)\n- [2.12.0](/cpp/docs/reference/talent/2.12.0/talent_v4_1_1JobServiceClient-retry-snippet)\n- [2.11.0](/cpp/docs/reference/talent/2.11.0/talent_v4_1_1JobServiceClient-retry-snippet) \n\nOverride talent_v4::JobServiceClient Retry Policies\n===================================================\n\nThis shows how to override the retry policies for talent_v4::JobServiceClient: \n\n auto options =\n google::cloud::Options{}\n .set\u003cgoogle::cloud::talent_v4::\n JobServiceConnectionIdempotencyPolicyOption\u003e(\n CustomIdempotencyPolicy().clone())\n .set\u003cgoogle::cloud::talent_v4::JobServiceRetryPolicyOption\u003e(\n google::cloud::talent_v4::JobServiceLimitedErrorCountRetryPolicy(\n 3)\n .clone())\n .set\u003cgoogle::cloud::talent_v4::JobServiceBackoffPolicyOption\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 = google::cloud::talent_v4::MakeJobServiceConnection(options);\n\n // c1 and c2 share the same retry policies\n auto c1 = google::cloud::talent_v4::JobServiceClient(connection);\n auto c2 = google::cloud::talent_v4::JobServiceClient(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::talent_v4::JobServiceClient(\n connection,\n google::cloud::Options{}\n .set\u003cgoogle::cloud::talent_v4::JobServiceRetryPolicyOption\u003e(\n google::cloud::talent_v4::JobServiceLimitedTimeRetryPolicy(\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::talent_v4::JobServiceRetryPolicyOption\u003e(\n // google::cloud::talent_v4::JobServiceLimitedErrorCountRetryPolicy(10).clone()));\n\nAssuming you have created a custom idempotency policy. Such as: \n\n class CustomIdempotencyPolicy\n : public google::cloud::talent_v4::JobServiceConnectionIdempotencyPolicy {\n public:\n ~CustomIdempotencyPolicy() override = default;\n std::unique_ptr\u003c\n google::cloud::talent_v4::JobServiceConnectionIdempotencyPolicy\u003e\n clone() const override {\n return std::make_unique\u003cCustomIdempotencyPolicy\u003e(*this);\n }\n // Override inherited functions to define as needed.\n };"]]