Couchbase C++ SDK
1.4.0 (rev. 59aa900)
Toggle main menu visibility
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
20
#include <
couchbase/retry_strategy.hxx
>
21
22
#include <chrono>
23
#include <functional>
24
#include <memory>
25
26
namespace
couchbase
27
{
28
using
backoff_calculator
= std::function<std::chrono::milliseconds(std::size_t retry_attempts)>;
29
33
auto
34
controlled_backoff
(std::size_t retry_attempts) -> std::chrono::milliseconds;
35
44
auto
45
exponential_backoff
(std::chrono::milliseconds min_backoff,
46
std::chrono::milliseconds max_backoff,
47
double
backoff_factor) ->
backoff_calculator
;
48
49
class
best_effort_retry_strategy
:
public
retry_strategy
50
{
51
public
:
52
explicit
best_effort_retry_strategy
(
backoff_calculator
calculator);
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
59
private:
60
backoff_calculator
backoff_calculator_;
61
};
62
63
[[nodiscard]] auto
64
make_best_effort_retry_strategy
(
backoff_calculator
calculator =
controlled_backoff
)
65
-> std::shared_ptr<
best_effort_retry_strategy
>;
66
}
// namespace couchbase
couchbase::best_effort_retry_strategy
Definition
best_effort_retry_strategy.hxx:50
couchbase::best_effort_retry_strategy::to_string
auto to_string() const -> std::string override
couchbase::best_effort_retry_strategy::best_effort_retry_strategy
best_effort_retry_strategy(backoff_calculator calculator)
couchbase::best_effort_retry_strategy::retry_after
auto retry_after(const retry_request &request, retry_reason reason) -> retry_action override
couchbase::best_effort_retry_strategy::~best_effort_retry_strategy
~best_effort_retry_strategy() override=default
couchbase::retry_action
Definition
retry_action.hxx:25
couchbase::retry_request
Definition
retry_request.hxx:28
couchbase::retry_strategy::retry_strategy
retry_strategy()=default
couchbase
Represents a single item from the result of scan().
Definition
allow_querying_search_index_options.hxx:28
couchbase::make_best_effort_retry_strategy
auto make_best_effort_retry_strategy(backoff_calculator calculator=controlled_backoff) -> std::shared_ptr< best_effort_retry_strategy >
couchbase::controlled_backoff
auto controlled_backoff(std::size_t retry_attempts) -> std::chrono::milliseconds
calculates a backoff time duration from the retry attempts on a given request.
couchbase::exponential_backoff
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.
couchbase::retry_reason
retry_reason
Enumeration of possible retry reasons for operations.
Definition
retry_reason.hxx:28
couchbase::backoff_calculator
std::function< std::chrono::milliseconds(std::size_t retry_attempts)> backoff_calculator
Definition
best_effort_retry_strategy.hxx:28
retry_strategy.hxx
couchbase
best_effort_retry_strategy.hxx
Generated by
1.17.0