Google Cloud Storage C++ Client 2.11.0
A C++ Client Library for Google Cloud Storage
Loading...
Searching...
No Matches
retry_policy.h
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
23namespace google {
24namespace cloud {
25namespace storage {
26GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
27namespace internal {
28/// Defines what error codes are permanent errors.
29struct StatusTraits {
30 static bool IsPermanentFailure(Status const& status) {
31 return status.code() != StatusCode::kDeadlineExceeded &&
32 status.code() != StatusCode::kInternal &&
33 status.code() != StatusCode::kResourceExhausted &&
34 status.code() != StatusCode::kUnavailable;
35 }
36};
37} // namespace internal
38
39/// The retry policy base class
40using RetryPolicy =
41 ::google::cloud::internal::TraitBasedRetryPolicy<internal::StatusTraits>;
42
43/// Keep retrying until some time has expired.
44using LimitedTimeRetryPolicy =
45 ::google::cloud::internal::LimitedTimeRetryPolicy<internal::StatusTraits>;
46
47/// Keep retrying until the error count has been exceeded.
48using LimitedErrorCountRetryPolicy =
49 ::google::cloud::internal::LimitedErrorCountRetryPolicy<
50 internal::StatusTraits>;
51
52/// The backoff policy base class.
53using BackoffPolicy = ::google::cloud::internal::BackoffPolicy;
54
55/// Implement truncated exponential backoff with randomization.
56using ExponentialBackoffPolicy =
57 ::google::cloud::internal::ExponentialBackoffPolicy;
58
59GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
60} // namespace storage
61} // namespace cloud
62} // namespace google
63
64#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_RETRY_POLICY_H
StatusCode code() const
Contains all the Google Cloud Storage C++ client APIs.
Definition: auto_finalize.h:24