diff options
author | alexromanov <alexromanov@yandex-team.ru> | 2022-02-10 16:50:09 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:50:09 +0300 |
commit | 1072ee1402b5fb9b10d1bc5fe5bf4f50b1316d41 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library | |
parent | 1862120cb626cb11ea2af213e3eea99e0c7f3dac (diff) | |
download | ydb-1072ee1402b5fb9b10d1bc5fe5bf4f50b1316d41.tar.gz |
Restoring authorship annotation for <alexromanov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library')
-rw-r--r-- | library/cpp/deprecated/ya.make | 2 | ||||
-rw-r--r-- | library/cpp/retry/retry.cpp | 4 | ||||
-rw-r--r-- | library/cpp/retry/retry.h | 24 |
3 files changed, 15 insertions, 15 deletions
diff --git a/library/cpp/deprecated/ya.make b/library/cpp/deprecated/ya.make index ce867c91ae..6c753f68a9 100644 --- a/library/cpp/deprecated/ya.make +++ b/library/cpp/deprecated/ya.make @@ -29,7 +29,7 @@ RECURSE( omni/usage omni/ut prog_options - prog_options/ut + prog_options/ut sgi_hash threadable transgene diff --git a/library/cpp/retry/retry.cpp b/library/cpp/retry/retry.cpp index 5ddfcecd62..92466cdeca 100644 --- a/library/cpp/retry/retry.cpp +++ b/library/cpp/retry/retry.cpp @@ -11,8 +11,8 @@ bool DoWithRetryOnRetCode(std::function<bool()> func, TRetryOptions retryOptions if (func()) { return true; } - auto sleep = retryOptions.SleepFunction; - sleep(retryOptions.GetTimeToSleep(attempt)); + auto sleep = retryOptions.SleepFunction; + sleep(retryOptions.GetTimeToSleep(attempt)); } return false; } diff --git a/library/cpp/retry/retry.h b/library/cpp/retry/retry.h index b8297e9c52..c47ff5070f 100644 --- a/library/cpp/retry/retry.h +++ b/library/cpp/retry/retry.h @@ -19,17 +19,17 @@ struct TRetryOptions { TDuration SleepIncrement; TDuration SleepExponentialMultiplier; - std::function<void(TDuration)> SleepFunction; - + std::function<void(TDuration)> SleepFunction; + TRetryOptions(ui32 retryCount = 3, TDuration sleepDuration = TDuration::Seconds(1), TDuration sleepRandomDelta = TDuration::Zero(), - TDuration sleepIncrement = TDuration::Zero(), TDuration sleepExponentialMultiplier = TDuration::Zero(), - std::function<void(TDuration)> sleepFunction = [](TDuration d) { Sleep(d); }) // can't use Sleep itself due to Win compilation error + TDuration sleepIncrement = TDuration::Zero(), TDuration sleepExponentialMultiplier = TDuration::Zero(), + std::function<void(TDuration)> sleepFunction = [](TDuration d) { Sleep(d); }) // can't use Sleep itself due to Win compilation error : RetryCount(retryCount) , SleepDuration(sleepDuration) , SleepRandomDelta(sleepRandomDelta) , SleepIncrement(sleepIncrement) , SleepExponentialMultiplier(sleepExponentialMultiplier) - , SleepFunction(sleepFunction) + , SleepFunction(sleepFunction) { } @@ -58,11 +58,11 @@ struct TRetryOptions { return *this; } - TRetryOptions& WithSleepFunction(std::function<void(TDuration)> sleepFunction) { - SleepFunction = sleepFunction; - return *this; - } - + TRetryOptions& WithSleepFunction(std::function<void(TDuration)> sleepFunction) { + SleepFunction = sleepFunction; + return *this; + } + // for compatibility attempt == 0 by default TDuration GetTimeToSleep(ui32 attempt = 0) const { return SleepDuration + NRetryPrivate::AddRandomDelta(SleepRandomDelta) + NRetryPrivate::AddIncrement(attempt, SleepIncrement) + NRetryPrivate::AddExponentialMultiplier(attempt, SleepExponentialMultiplier); @@ -93,8 +93,8 @@ TMaybe<TResult> DoWithRetry(std::function<TResult()> func, std::function<void(co throw; } } else { - auto sleep = retryOptions.SleepFunction; - sleep(retryOptions.GetTimeToSleep(attempt)); + auto sleep = retryOptions.SleepFunction; + sleep(retryOptions.GetTimeToSleep(attempt)); } } } |