summaryrefslogtreecommitdiff
path: root/src/buildtool/storage/config.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/buildtool/storage/config.hpp')
-rw-r--r--src/buildtool/storage/config.hpp33
1 files changed, 25 insertions, 8 deletions
diff --git a/src/buildtool/storage/config.hpp b/src/buildtool/storage/config.hpp
index dd569c46..884dae48 100644
--- a/src/buildtool/storage/config.hpp
+++ b/src/buildtool/storage/config.hpp
@@ -28,7 +28,6 @@
#include <string>
#include <vector>
-#include <fmt/core.h>
#include <nlohmann/json.hpp>
#include "src/buildtool/common/artifact_digest.hpp"
@@ -137,19 +136,37 @@ class StorageConfig {
-> std::string {
auto address = RemoteExecutionConfig::RemoteAddress();
auto properties = RemoteExecutionConfig::PlatformProperties();
+ auto dispatch = RemoteExecutionConfig::DispatchList();
+ auto description = nlohmann::json{
+ {"remote_address", address ? address->ToJson() : nlohmann::json{}},
+ {"platform_properties", properties}};
+ if (!dispatch.empty()) {
+ try {
+ // only add the dispatch list, if not empty, so that keys remain
+ // not only more readable, but also backwards compatible with
+ // earlier versions.
+ auto dispatch_list = nlohmann::json::array();
+ for (auto const& [props, endpoint] : dispatch) {
+ auto entry = nlohmann::json::array();
+ entry.push_back(nlohmann::json(props));
+ entry.push_back(endpoint.ToJson());
+ dispatch_list.push_back(entry);
+ }
+ description["endpoint dispatch list"] = dispatch_list;
+ } catch (std::exception const& e) {
+ Logger::Log(LogLevel::Error,
+ "Failed to serialize endpoint dispatch list: {}",
+ e.what());
+ }
+ }
try {
// json::dump with json::error_handler_t::replace will not throw an
// exception if invalid UTF-8 sequences are detected in the input.
// Instead, it will replace them with the UTF-8 replacement
// character, but still it needs to be inside a try-catch clause to
// ensure the noexcept modifier of the enclosing function.
- return nlohmann::json{
- {"remote_address",
- address ? nlohmann::json{fmt::format(
- "{}:{}", address->host, address->port)}
- : nlohmann::json{}},
- {"platform_properties", properties}}
- .dump(2, ' ', false, nlohmann::json::error_handler_t::replace);
+ return description.dump(
+ 2, ' ', false, nlohmann::json::error_handler_t::replace);
} catch (...) {
return "";
}