aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/retry/retry.h
diff options
context:
space:
mode:
authorelshiko <elshiko@yandex-team.ru>2022-02-10 16:49:20 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:20 +0300
commitdbb5d0d21c8cfc3d59e0f6d3b6f4ab06b58561f1 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/retry/retry.h
parent455ab915435b70e433ed91eee2ca84f03122d6cb (diff)
downloadydb-dbb5d0d21c8cfc3d59e0f6d3b6f4ab06b58561f1.tar.gz
Restoring authorship annotation for <elshiko@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/retry/retry.h')
-rw-r--r--library/cpp/retry/retry.h34
1 files changed, 17 insertions, 17 deletions
diff --git a/library/cpp/retry/retry.h b/library/cpp/retry/retry.h
index 478eb48197..c47ff5070f 100644
--- a/library/cpp/retry/retry.h
+++ b/library/cpp/retry/retry.h
@@ -82,12 +82,12 @@ struct TRetryOptions {
};
template <typename TResult, typename TException = yexception>
-TMaybe<TResult> DoWithRetry(std::function<TResult()> func, std::function<void(const TException&)> onFail, TRetryOptions retryOptions, bool throwLast) {
+TMaybe<TResult> DoWithRetry(std::function<TResult()> func, std::function<void(const TException&)> onFail, TRetryOptions retryOptions, bool throwLast) {
for (ui32 attempt = 0; attempt <= retryOptions.RetryCount; ++attempt) {
try {
return func();
- } catch (TException& ex) {
- onFail(ex);
+ } catch (TException& ex) {
+ onFail(ex);
if (attempt == retryOptions.RetryCount) {
if (throwLast) {
throw;
@@ -101,27 +101,27 @@ TMaybe<TResult> DoWithRetry(std::function<TResult()> func, std::function<void(co
return Nothing();
}
-template <typename TResult, typename TException = yexception>
-TMaybe<TResult> DoWithRetry(std::function<TResult()> func, TRetryOptions retryOptions, bool throwLast) {
- return DoWithRetry<TResult, TException>(func, [](const TException&){}, retryOptions, throwLast);
-}
-
+template <typename TResult, typename TException = yexception>
+TMaybe<TResult> DoWithRetry(std::function<TResult()> func, TRetryOptions retryOptions, bool throwLast) {
+ return DoWithRetry<TResult, TException>(func, [](const TException&){}, retryOptions, throwLast);
+}
+
template <typename TException = yexception>
bool DoWithRetry(std::function<void()> func, std::function<void(const TException&)> onFail, TRetryOptions retryOptions, bool throwLast) {
- auto f = [&]() {
- func();
- return nullptr;
- };
- return DoWithRetry<void*, TException>(f, onFail, retryOptions, throwLast).Defined();
-}
-
-template <typename TException = yexception>
+ auto f = [&]() {
+ func();
+ return nullptr;
+ };
+ return DoWithRetry<void*, TException>(f, onFail, retryOptions, throwLast).Defined();
+}
+
+template <typename TException = yexception>
bool DoWithRetry(std::function<void()> func, TRetryOptions retryOptions, bool throwLast) {
auto f = [&]() {
func();
return nullptr;
};
- return DoWithRetry<void*, TException>(f, [](const TException&){}, retryOptions, throwLast).Defined();
+ return DoWithRetry<void*, TException>(f, [](const TException&){}, retryOptions, throwLast).Defined();
}
void DoWithRetry(std::function<void()> func, TRetryOptions retryOptions);