summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2023-06-22 17:10:04 +0200
committerOliver Reiche <oliver.reiche@huawei.com>2023-07-05 13:08:38 +0200
commitee2da2be9d32426b7ab113005e417837b0ae5a1c (patch)
treef36816a27d9a5f533110e294b77e05fc05fb34ee
parentec40930a14c8b69ff0618f889517d75de12708cf (diff)
downloadjustbuild-ee2da2be9d32426b7ab113005e417837b0ae5a1c.tar.gz
Add serialisation of ServerAddress
... in a way consistent with what we're using at other places already.
-rw-r--r--src/buildtool/execution_api/remote/TARGETS2
-rw-r--r--src/buildtool/execution_api/remote/config.hpp7
2 files changed, 9 insertions, 0 deletions
diff --git a/src/buildtool/execution_api/remote/TARGETS b/src/buildtool/execution_api/remote/TARGETS
index 5a462481..2d08ff8e 100644
--- a/src/buildtool/execution_api/remote/TARGETS
+++ b/src/buildtool/execution_api/remote/TARGETS
@@ -70,7 +70,9 @@
, "deps":
[ ["src/buildtool/logging", "logging"]
, ["src/utils/cpp", "type_safe_arithmetic"]
+ , ["@", "fmt", "", "fmt"]
, ["@", "gsl", "", "gsl"]
+ , ["@", "json", "", "json"]
]
, "stage": ["src", "buildtool", "execution_api", "remote"]
}
diff --git a/src/buildtool/execution_api/remote/config.hpp b/src/buildtool/execution_api/remote/config.hpp
index b10c3b23..0b028035 100644
--- a/src/buildtool/execution_api/remote/config.hpp
+++ b/src/buildtool/execution_api/remote/config.hpp
@@ -23,6 +23,9 @@
#include <string>
#include <utility>
+#include <fmt/core.h>
+#include <nlohmann/json.hpp>
+
#include "gsl/gsl"
#include "src/buildtool/logging/logger.hpp"
#include "src/utils/cpp/type_safe_arithmetic.hpp"
@@ -61,6 +64,10 @@ class RemoteExecutionConfig {
struct ServerAddress {
std::string host{};
Port port{};
+
+ [[nodiscard]] auto ToJson() const noexcept -> nlohmann::json {
+ return nlohmann::json{fmt::format("{}:{}", host, port)};
+ }
};
// Obtain global instance