Google Cloud Storage C++ Client  1.42.0
A C++ Client Library for Google Cloud Storage
retry_policy.h
Go to the documentation of this file.
1 // Copyright 2018 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_RETRY_POLICY_H
16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_RETRY_POLICY_H
17 
18 #include "google/cloud/storage/version.h"
19 #include "google/cloud/internal/backoff_policy.h"
20 #include "google/cloud/internal/retry_policy.h"
21 #include "google/cloud/status.h"
22 
23 namespace google {
24 namespace cloud {
25 namespace storage {
27 namespace internal {
28 /// Defines what error codes are permanent errors.
29 struct StatusTraits {
30  static bool IsPermanentFailure(Status const& status) {
31  return status.code() != StatusCode::kDeadlineExceeded &&
32  status.code() != StatusCode::kInternal &&
35  }
36 };
37 } // namespace internal
38 
39 /// The retry policy base class
40 using RetryPolicy =
41  ::google::cloud::internal::TraitBasedRetryPolicy<internal::StatusTraits>;
42 
43 /// Keep retrying until some time has expired.
44 using LimitedTimeRetryPolicy =
45  ::google::cloud::internal::LimitedTimeRetryPolicy<internal::StatusTraits>;
46 
47 /// Keep retrying until the error count has been exceeded.
48 using LimitedErrorCountRetryPolicy =
49  ::google::cloud::internal::LimitedErrorCountRetryPolicy<
50  internal::StatusTraits>;
51 
52 /// The backoff policy base class.
53 using BackoffPolicy = ::google::cloud::internal::BackoffPolicy;
54 
55 /// Implement truncated exponential backoff with randomization.
56 using ExponentialBackoffPolicy =
57  ::google::cloud::internal::ExponentialBackoffPolicy;
58 
60 } // namespace storage
61 } // namespace cloud
62 } // namespace google
63 
64 #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_RETRY_POLICY_H