diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-07-15 14:40:15 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-07-16 17:51:12 +0200 |
commit | 6c95b7c6e20467270da26cd5d10111bb9307c065 (patch) | |
tree | 7646515782153e60427ee8a07532b2df07e7e012 /src/buildtool/common/remote/remote_common.hpp | |
parent | 978de9de55d9592c258052dd52dc25c788a89d78 (diff) | |
download | justbuild-6c95b7c6e20467270da26cd5d10111bb9307c065.tar.gz |
Add useful aliases for platform properties and dispatch endpoint
Diffstat (limited to 'src/buildtool/common/remote/remote_common.hpp')
-rw-r--r-- | src/buildtool/common/remote/remote_common.hpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/buildtool/common/remote/remote_common.hpp b/src/buildtool/common/remote/remote_common.hpp index 0f995dd5..92adda0b 100644 --- a/src/buildtool/common/remote/remote_common.hpp +++ b/src/buildtool/common/remote/remote_common.hpp @@ -37,6 +37,10 @@ struct ServerAddress { } }; +// Useful additional types +using ExecutionProperties = std::map<std::string, std::string>; +using DispatchEndpoint = std::pair<ExecutionProperties, ServerAddress>; + [[nodiscard]] static auto ParseAddress(std::string const& address) noexcept -> std::optional<ServerAddress> { std::istringstream iss(address); @@ -63,10 +67,9 @@ struct ServerAddress { return std::make_pair(key, val); } -[[nodiscard]] static auto -ParseDispatch(std::string const& dispatch_info) noexcept -> expected< - std::vector<std::pair<std::map<std::string, std::string>, ServerAddress>>, - std::string> { +[[nodiscard]] static auto ParseDispatch( + std::string const& dispatch_info) noexcept + -> expected<std::vector<DispatchEndpoint>, std::string> { nlohmann::json dispatch; try { dispatch = nlohmann::json::parse(dispatch_info); @@ -74,8 +77,7 @@ ParseDispatch(std::string const& dispatch_info) noexcept -> expected< return unexpected{fmt::format( "Failed to parse endpoint configuration: {}", e.what())}; } - std::vector<std::pair<std::map<std::string, std::string>, ServerAddress>> - parsed{}; + std::vector<DispatchEndpoint> parsed{}; try { if (not dispatch.is_array()) { return unexpected{ @@ -96,7 +98,7 @@ ParseDispatch(std::string const& dispatch_info) noexcept -> expected< "given as an object, but found {}", entry[0].dump())}; } - std::map<std::string, std::string> props{}; + ExecutionProperties props{}; for (auto const& [k, v] : entry[0].items()) { if (not v.is_string()) { return unexpected{ |