aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/retry/retry.h
diff options
context:
space:
mode:
authortolich <tolich@yandex-team.ru>2022-02-10 16:48:42 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:42 +0300
commitc662862405cbda305d8b2ff7693adf2595e3edc2 (patch)
tree8e90f9839e52b2f919afad2548603e234c09236f /library/cpp/retry/retry.h
parent4de04c154cab33e0eba93458503743261ec13de4 (diff)
downloadydb-c662862405cbda305d8b2ff7693adf2595e3edc2.tar.gz
Restoring authorship annotation for <tolich@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/retry/retry.h')
-rw-r--r--library/cpp/retry/retry.h40
1 files changed, 20 insertions, 20 deletions
diff --git a/library/cpp/retry/retry.h b/library/cpp/retry/retry.h
index c47ff5070f..d4f1648dec 100644
--- a/library/cpp/retry/retry.h
+++ b/library/cpp/retry/retry.h
@@ -12,23 +12,23 @@
struct TRetryOptions {
ui32 RetryCount;
-
- // TotalDuration = SleepDuration +/- SleepRandomDelta + (attempt * SleepIncrement) + (2**attempt * SleepExponentialMultiplier)
+
+ // TotalDuration = SleepDuration +/- SleepRandomDelta + (attempt * SleepIncrement) + (2**attempt * SleepExponentialMultiplier)
TDuration SleepDuration;
- TDuration SleepRandomDelta;
- TDuration SleepIncrement;
- TDuration SleepExponentialMultiplier;
+ TDuration SleepRandomDelta;
+ TDuration SleepIncrement;
+ TDuration SleepExponentialMultiplier;
std::function<void(TDuration)> SleepFunction;
- TRetryOptions(ui32 retryCount = 3, TDuration sleepDuration = TDuration::Seconds(1), TDuration sleepRandomDelta = TDuration::Zero(),
+ 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
: RetryCount(retryCount)
, SleepDuration(sleepDuration)
, SleepRandomDelta(sleepRandomDelta)
- , SleepIncrement(sleepIncrement)
- , SleepExponentialMultiplier(sleepExponentialMultiplier)
+ , SleepIncrement(sleepIncrement)
+ , SleepExponentialMultiplier(sleepExponentialMultiplier)
, SleepFunction(sleepFunction)
{
}
@@ -48,26 +48,26 @@ struct TRetryOptions {
return *this;
}
- TRetryOptions& WithIncrement(TDuration sleepIncrement) {
- SleepIncrement = sleepIncrement;
- return *this;
- }
-
- TRetryOptions& WithExponentialMultiplier(TDuration sleepExponentialMultiplier) {
- SleepExponentialMultiplier = sleepExponentialMultiplier;
- return *this;
+ TRetryOptions& WithIncrement(TDuration sleepIncrement) {
+ SleepIncrement = sleepIncrement;
+ return *this;
}
+ TRetryOptions& WithExponentialMultiplier(TDuration sleepExponentialMultiplier) {
+ SleepExponentialMultiplier = sleepExponentialMultiplier;
+ 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 {
+ // 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);
- }
-
+ }
+
static TRetryOptions Count(ui32 retryCount) {
return TRetryOptions(retryCount);
}