summaryrefslogtreecommitdiff
path: root/src/buildtool/common/remote/retry.cpp
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-07-16 15:51:24 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-07-19 09:50:37 +0200
commit953fc900629dd2b04c509b4f953e75dd351e09d9 (patch)
tree074258da62e9c2d58cd4998ba9f1ac0e595d1cc8 /src/buildtool/common/remote/retry.cpp
parent2361355beb80685157b2a0cf6f79c14e010a00de (diff)
downloadjustbuild-953fc900629dd2b04c509b4f953e75dd351e09d9.tar.gz
Pass RetryConfig instance to WithRetry
Diffstat (limited to 'src/buildtool/common/remote/retry.cpp')
-rw-r--r--src/buildtool/common/remote/retry.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/buildtool/common/remote/retry.cpp b/src/buildtool/common/remote/retry.cpp
index 5d75585c..785cfa65 100644
--- a/src/buildtool/common/remote/retry.cpp
+++ b/src/buildtool/common/remote/retry.cpp
@@ -18,13 +18,13 @@
#include <chrono>
#include <thread>
-#include "src/buildtool/common/remote/retry_config.hpp"
#include "src/buildtool/logging/log_level.hpp"
auto WithRetry(CallableReturningRetryResponse const& f,
+ RetryConfig const& retry_config,
Logger const& logger) noexcept -> bool {
try {
- auto const& attempts = RetryConfig::GetMaxAttempts();
+ auto const& attempts = retry_config.GetMaxAttempts();
for (auto attempt = 1U; attempt <= attempts; ++attempt) {
auto [ok, fatal, error_msg] = f();
if (ok) {
@@ -39,7 +39,7 @@ auto WithRetry(CallableReturningRetryResponse const& f,
// don't wait if it was the last attempt
if (attempt < attempts) {
auto const sleep_for_seconds =
- RetryConfig::GetSleepTimeSeconds(attempt);
+ retry_config.GetSleepTimeSeconds(attempt);
logger.Emit(kRetryLogLevel,
"Attempt {}/{} failed{} Retrying in {} seconds.",
attempt,
@@ -64,10 +64,11 @@ auto WithRetry(CallableReturningRetryResponse const& f,
return false;
}
auto WithRetry(CallableReturningGrpcStatus const& f,
+ RetryConfig const& retry_config,
Logger const& logger) noexcept -> std::pair<bool, grpc::Status> {
grpc::Status status{};
try {
- auto attempts = RetryConfig::GetMaxAttempts();
+ auto attempts = retry_config.GetMaxAttempts();
for (auto attempt = 1U; attempt <= attempts; ++attempt) {
status = f();
if (status.ok() or
@@ -77,7 +78,7 @@ auto WithRetry(CallableReturningGrpcStatus const& f,
// don't wait if it was the last attempt
if (attempt < attempts) {
auto const sleep_for_seconds =
- RetryConfig::GetSleepTimeSeconds(attempt);
+ retry_config.GetSleepTimeSeconds(attempt);
logger.Emit(
kRetryLogLevel,
"Attempt {}/{} failed: {}: {}: Retrying in {} seconds.",