Couchbase C++ SDK 1.0.4 (rev. 5355b0f)
Loading...
Searching...
No Matches
best_effort_retry_strategy.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * Copyright 2022-Present Couchbase, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#pragma once
19
21
22#include <chrono>
23#include <functional>
24#include <memory>
25
26namespace couchbase
27{
28using backoff_calculator = std::function<std::chrono::milliseconds(std::size_t retry_attempts)>;
29
33auto
34controlled_backoff(std::size_t retry_attempts) -> std::chrono::milliseconds;
35
44auto
45exponential_backoff(std::chrono::milliseconds min_backoff,
46 std::chrono::milliseconds max_backoff,
47 double backoff_factor) -> backoff_calculator;
48
50{
51public:
53 ~best_effort_retry_strategy() override = default;
54
55 auto retry_after(const retry_request& request, retry_reason reason) -> retry_action override;
56
57 [[nodiscard]] auto to_string() const -> std::string override;
58
59private:
60 backoff_calculator backoff_calculator_;
61};
62
63[[nodiscard]] auto
65 -> std::shared_ptr<best_effort_retry_strategy>;
66} // namespace couchbase
Definition best_effort_retry_strategy.hxx:50
auto to_string() const -> std::string override
best_effort_retry_strategy(backoff_calculator calculator)
auto retry_after(const retry_request &request, retry_reason reason) -> retry_action override
~best_effort_retry_strategy() override=default
Definition retry_action.hxx:25
Definition retry_request.hxx:28
Definition retry_strategy.hxx:29
Represents a single item from the result of collection::scan()
Definition allow_querying_search_index_options.hxx:28
auto make_best_effort_retry_strategy(backoff_calculator calculator=controlled_backoff) -> std::shared_ptr< best_effort_retry_strategy >
auto controlled_backoff(std::size_t retry_attempts) -> std::chrono::milliseconds
calculates a backoff time duration from the retry attempts on a given request.
auto exponential_backoff(std::chrono::milliseconds min_backoff, std::chrono::milliseconds max_backoff, double backoff_factor) -> backoff_calculator
calculates a backoff time duration from the retry attempts on a given request.
retry_reason
Enumeration of possible retry reasons for operations.
Definition retry_reason.hxx:28
std::function< std::chrono::milliseconds(std::size_t retry_attempts)> backoff_calculator
Definition best_effort_retry_strategy.hxx:28