<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [2.13.0-rc (latest)](https://docs.cloud.google.com/cpp/docs/reference/gameservices/latest/gameservices_v1_1_1GameServerDeploymentsServiceClient-retry-snippet)
- [2.12.0](https://docs.cloud.google.com/cpp/docs/reference/gameservices/2.12.0/gameservices_v1_1_1GameServerDeploymentsServiceClient-retry-snippet)
- [2.11.0](https://docs.cloud.google.com/cpp/docs/reference/gameservices/2.11.0/gameservices_v1_1_1GameServerDeploymentsServiceClient-retry-snippet)

# Override gameservices_v1::GameServerDeploymentsServiceClient Retry Policies

This shows how to override the retry policies for gameservices_v1::GameServerDeploymentsServiceClient:

      auto options =
          google::cloud::Options{}
              .set<
                  google::cloud::gameservices_v1::
                      GameServerDeploymentsServiceConnectionIdempotencyPolicyOption>(
                  CustomIdempotencyPolicy().clone())
              .set<google::cloud::gameservices_v1::
                       GameServerDeploymentsServiceRetryPolicyOption>(
                  google::cloud::gameservices_v1::
                      GameServerDeploymentsServiceLimitedErrorCountRetryPolicy(3)
                          .clone())
              .set<google::cloud::gameservices_v1::
                       GameServerDeploymentsServiceBackoffPolicyOption>(
                  google::cloud::ExponentialBackoffPolicy(
                      /*initial_delay=*/std::chrono::milliseconds(200),
                      /*maximum_delay=*/std::chrono::seconds(45),
                      /*scaling=*/2.0)
                      .clone());
      auto connection = google::cloud::gameservices_v1::
          MakeGameServerDeploymentsServiceConnection(options);

      // c1 and c2 share the same retry policies
      auto c1 = google::cloud::gameservices_v1::GameServerDeploymentsServiceClient(
          connection);
      auto c2 = google::cloud::gameservices_v1::GameServerDeploymentsServiceClient(
          connection);

      // You can override any of the policies in a new client. This new client
      // will share the policies from c1 (or c2) *except* from the retry policy.
      auto c3 = google::cloud::gameservices_v1::GameServerDeploymentsServiceClient(
          connection,
          google::cloud::Options{}
              .set<google::cloud::gameservices_v1::
                       GameServerDeploymentsServiceRetryPolicyOption>(
                  google::cloud::gameservices_v1::
                      GameServerDeploymentsServiceLimitedTimeRetryPolicy(
                          std::chrono::minutes(5))
                          .clone()));

      // You can also override the policies in a single call:
      // c3.SomeRpc(..., google::cloud::Options{}
      //     .set<google::cloud::gameservices_v1::GameServerDeploymentsServiceRetryPolicyOption>(
      //       google::cloud::gameservices_v1::GameServerDeploymentsServiceLimitedErrorCountRetryPolicy(10).clone()));

Assuming you have created a custom idempotency policy. Such as:

    class CustomIdempotencyPolicy
        : public google::cloud::gameservices_v1::
              GameServerDeploymentsServiceConnectionIdempotencyPolicy {
     public:
      ~CustomIdempotencyPolicy() override = default;
      std::unique_ptr<google::cloud::gameservices_v1::
                          GameServerDeploymentsServiceConnectionIdempotencyPolicy>
      clone() const override {
        return std::make_unique<CustomIdempotencyPolicy>(*this);
      }
      // Override inherited functions to define as needed.
    };