From 741773f63fa24d2c862db32cb46a0edfbd69968b Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Tue, 16 Jul 2024 16:53:36 +0200 Subject: just: Move RetryConfig setup before starting just serve As the serve endpoint acts also as a regular client to its associated remote-execution endpoint, it should employ the same retry strategy as the regular just client. Also updates ReadJustServeConfig to store the retry config arguments instead of calling the RetryConfig singleton setters directly, thus clearly separating the reading of the arguments from the creation of any configuration singleton/instance. --- src/buildtool/main/serve.cpp | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) (limited to 'src/buildtool/main/serve.cpp') diff --git a/src/buildtool/main/serve.cpp b/src/buildtool/main/serve.cpp index e5dec606..87f1c9ac 100644 --- a/src/buildtool/main/serve.cpp +++ b/src/buildtool/main/serve.cpp @@ -31,7 +31,6 @@ #include "src/buildtool/build_engine/expression/configuration.hpp" #include "src/buildtool/build_engine/expression/expression.hpp" #include "src/buildtool/common/location.hpp" -#include "src/buildtool/common/remote/retry_config.hpp" #include "src/buildtool/file_system/file_system_manager.hpp" #include "src/buildtool/logging/log_level.hpp" #include "src/buildtool/logging/logger.hpp" @@ -56,8 +55,9 @@ namespace { } // namespace -[[nodiscard]] auto ParseRetryCliOptions(Configuration const& config) noexcept - -> bool { +[[nodiscard]] auto ParseRetryCliOptions( + Configuration const& config, + gsl::not_null const& rargs) noexcept -> bool { auto max_attempts = config["max-attempts"]; if (max_attempts.IsNotNull()) { if (!max_attempts->IsNumber()) { @@ -67,12 +67,7 @@ namespace { max_attempts->ToString()); return false; } - if (!RetryConfig::SetMaxAttempts(max_attempts->Number())) { - Logger::Log(LogLevel::Error, - "Invalid value for \"max-attempts\" {}.", - max_attempts->Number()); - return false; - } + rargs->max_attempts = static_cast(max_attempts->Number()); } auto initial_backoff = config["initial-backoff-seconds"]; if (initial_backoff.IsNotNull()) { @@ -83,12 +78,8 @@ namespace { initial_backoff->ToString()); return false; } - if (!RetryConfig::SetMaxAttempts(initial_backoff->Number())) { - Logger::Log(LogLevel::Error, - "Invalid value for \"initial-backoff-seconds\" {}.", - initial_backoff->Number()); - return false; - } + rargs->initial_backoff_seconds = + static_cast(initial_backoff->Number()); } auto max_backoff = config["max-backoff-seconds"]; if (max_backoff.IsNotNull()) { @@ -99,12 +90,8 @@ namespace { max_backoff->ToString()); return false; } - if (!RetryConfig::SetMaxAttempts(max_backoff->Number())) { - Logger::Log(LogLevel::Error, - "Invalid value for \"max-backoff-seconds\" {}.", - max_backoff->Number()); - return false; - } + rargs->max_backoff_seconds = + static_cast(max_backoff->Number()); } return true; } @@ -420,7 +407,7 @@ void ReadJustServeConfig(gsl::not_null const& clargs) { } clargs->endpoint.remote_execution_address = address->String(); } - if (!ParseRetryCliOptions(serve_config)) { + if (!ParseRetryCliOptions(serve_config, &clargs->retry)) { std::exit(kExitFailure); } } -- cgit v1.2.3