diff options
author | Alberto Sartori <alberto.sartori@huawei.com> | 2023-12-11 18:26:16 +0100 |
---|---|---|
committer | Alberto Sartori <alberto.sartori@huawei.com> | 2023-12-13 23:04:36 +0100 |
commit | 0d01c2bcd670f5600c337b87115e089f6d48aab5 (patch) | |
tree | 702c21459952c126d1a67430324f93004fe36d04 /src/buildtool/main/main.cpp | |
parent | 9b3eb0e818f25be8a49b441a55991bcf86697548 (diff) | |
download | justbuild-0d01c2bcd670f5600c337b87115e089f6d48aab5.tar.gz |
Add command line options to tune the retry strategy for rpc calls
Three new command line options have been added:
- `--max-attempts`
- `--initial-backoff-seconds`
- `--max-backoff-seconds`
Diffstat (limited to 'src/buildtool/main/main.cpp')
-rw-r--r-- | src/buildtool/main/main.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp index ad1447be..50b8f476 100644 --- a/src/buildtool/main/main.cpp +++ b/src/buildtool/main/main.cpp @@ -42,6 +42,7 @@ #include "src/buildtool/storage/target_cache.hpp" #ifndef BOOTSTRAP_BUILD_TOOL #include "src/buildtool/auth/authentication.hpp" +#include "src/buildtool/common/remote/retry_parameters.hpp" #include "src/buildtool/execution_api/execution_service/operation_cache.hpp" #include "src/buildtool/execution_api/execution_service/server_implementation.hpp" #include "src/buildtool/execution_api/remote/config.hpp" @@ -309,6 +310,29 @@ void SetupHashFunction() { : HashFunction::JustHash::Native); } +void SetupRetryConfig(RetryArguments const& args) { + if (args.max_attempts) { + if (!Retry::SetMaxAttempts(*args.max_attempts)) { + Logger::Log(LogLevel::Error, "Invalid value for max-attempts."); + std::exit(kExitFailure); + } + } + if (args.initial_backoff_seconds) { + if (!Retry::SetInitialBackoffSeconds(*args.initial_backoff_seconds)) { + Logger::Log(LogLevel::Error, + "Invalid value for initial-backoff-seconds."); + std::exit(kExitFailure); + } + } + if (args.max_backoff_seconds) { + if (!Retry::SetMaxBackoffSeconds(*args.max_backoff_seconds)) { + Logger::Log(LogLevel::Error, + "Invalid value for max-backoff-seconds."); + std::exit(kExitFailure); + } + } +} + #endif // BOOTSTRAP_BUILD_TOOL // returns path relative to `root`. @@ -881,6 +905,7 @@ auto main(int argc, char* argv[]) -> int { : std::nullopt; #ifndef BOOTSTRAP_BUILD_TOOL + SetupRetryConfig(arguments.retry); GraphTraverser const traverser{{jobs, std::move(arguments.build), std::move(stage_args), |