summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/main/TARGETS1
-rw-r--r--src/buildtool/main/serve.cpp57
2 files changed, 58 insertions, 0 deletions
diff --git a/src/buildtool/main/TARGETS b/src/buildtool/main/TARGETS
index 21ed04aa..d955e766 100644
--- a/src/buildtool/main/TARGETS
+++ b/src/buildtool/main/TARGETS
@@ -202,6 +202,7 @@
, ["src/buildtool/logging", "log_level"]
, ["src/buildtool/logging", "logging"]
, "common"
+ , ["src/buildtool/common/remote", "retry_parameters"]
]
}
, "build_utils":
diff --git a/src/buildtool/main/serve.cpp b/src/buildtool/main/serve.cpp
index 32da7801..1a2add16 100644
--- a/src/buildtool/main/serve.cpp
+++ b/src/buildtool/main/serve.cpp
@@ -23,11 +23,65 @@
#include "nlohmann/json.hpp"
#include "src/buildtool/build_engine/expression/configuration.hpp"
#include "src/buildtool/build_engine/expression/expression.hpp"
+#include "src/buildtool/common/remote/retry_parameters.hpp"
#include "src/buildtool/file_system/file_system_manager.hpp"
#include "src/buildtool/logging/log_level.hpp"
#include "src/buildtool/logging/logger.hpp"
#include "src/buildtool/main/exit_codes.hpp"
+[[nodiscard]] auto ParseRetryCliOptions(Configuration const& config) noexcept
+ -> bool {
+ auto max_attempts = config["max-attempts"];
+ if (max_attempts.IsNotNull()) {
+ if (!max_attempts->IsNumber()) {
+ Logger::Log(
+ LogLevel::Error,
+ "Invalid value for \"max-attempts\" {}. It must be a number.",
+ max_attempts->ToString());
+ return false;
+ }
+ if (!Retry::SetMaxAttempts(max_attempts->Number())) {
+ Logger::Log(LogLevel::Error,
+ "Invalid value for \"max-attempts\" {}.",
+ max_attempts->Number());
+ return false;
+ }
+ }
+ auto initial_backoff = config["initial-backoff-seconds"];
+ if (initial_backoff.IsNotNull()) {
+ if (!initial_backoff->IsNumber()) {
+ Logger::Log(LogLevel::Error,
+ "Invalid value \"initial-backoff-seconds\" {}. It must "
+ "be a number.",
+ initial_backoff->ToString());
+ return false;
+ }
+ if (!Retry::SetMaxAttempts(initial_backoff->Number())) {
+ Logger::Log(LogLevel::Error,
+ "Invalid value for \"initial-backoff-seconds\" {}.",
+ initial_backoff->Number());
+ return false;
+ }
+ }
+ auto max_backoff = config["max-backoff-seconds"];
+ if (max_backoff.IsNotNull()) {
+ if (!max_backoff->IsNumber()) {
+ Logger::Log(LogLevel::Error,
+ "Invalid value for \"max-backoff-seconds\" {}. It must "
+ "be a number.",
+ max_backoff->ToString());
+ return false;
+ }
+ if (!Retry::SetMaxAttempts(max_backoff->Number())) {
+ Logger::Log(LogLevel::Error,
+ "Invalid value for \"max-backoff-seconds\" {}.",
+ max_backoff->Number());
+ return false;
+ }
+ }
+ return true;
+}
+
void ReadJustServeConfig(gsl::not_null<CommandLineArguments*> const& clargs) {
Configuration serve_config{};
if (FileSystemManager::IsFile(clargs->serve.config)) {
@@ -347,6 +401,9 @@ void ReadJustServeConfig(gsl::not_null<CommandLineArguments*> const& clargs) {
}
clargs->endpoint.remote_execution_address = address->String();
}
+ if (!ParseRetryCliOptions(serve_config)) {
+ std::exit(kExitFailure);
+ }
}
// read jobs value
auto jobs = serve_config["jobs"];