diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-09-21 18:19:58 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-09-22 11:16:21 +0200 |
commit | 9ef2ffa9acdc19453c81696aa2ed4da7cb84078c (patch) | |
tree | a27019dd1ffbee4c1a37fc2e6fd8a3e4a5ce62d0 /src/buildtool/serve_api/remote/config.hpp | |
parent | 1ac49337bdb752e42bc1bb6cb2e02fa6bb554462 (diff) | |
download | justbuild-9ef2ffa9acdc19453c81696aa2ed4da7cb84078c.tar.gz |
RemoteServeConfig: Remove problematic inheritance
This was causing the remote serve address to overwrite the one set
for remote execution.
Also, to keep things clean, some common remote server-related
methods and definitions were moved into their own library.
Diffstat (limited to 'src/buildtool/serve_api/remote/config.hpp')
-rw-r--r-- | src/buildtool/serve_api/remote/config.hpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/buildtool/serve_api/remote/config.hpp b/src/buildtool/serve_api/remote/config.hpp index dac7fabf..6ea927cb 100644 --- a/src/buildtool/serve_api/remote/config.hpp +++ b/src/buildtool/serve_api/remote/config.hpp @@ -16,9 +16,9 @@ #include <iterator> #include <vector> -#include "src/buildtool/execution_api/remote/config.hpp" +#include "src/buildtool/common/remote/remote_common.hpp" -class RemoteServeConfig : public RemoteExecutionConfig { +class RemoteServeConfig { public: // Obtain global instance [[nodiscard]] static auto Instance() noexcept -> RemoteServeConfig& { @@ -26,6 +26,13 @@ class RemoteServeConfig : public RemoteExecutionConfig { return config; } + // Set remote execution and cache address, unsets if parsing `address` fails + [[nodiscard]] static auto SetRemoteAddress( + std::string const& address) noexcept -> bool { + auto& inst = Instance(); + return static_cast<bool>(inst.remote_address_ = ParseAddress(address)); + } + // Set the list of known repositories [[nodiscard]] static auto SetKnownRepositories( std::vector<std::filesystem::path> const& repos) noexcept -> bool { @@ -36,6 +43,12 @@ class RemoteServeConfig : public RemoteExecutionConfig { return repos.size() == inst.repositories_.size(); } + // Remote execution address, if set + [[nodiscard]] static auto RemoteAddress() noexcept + -> std::optional<ServerAddress> { + return Instance().remote_address_; + } + // Repositories known to 'just serve' [[nodiscard]] static auto KnownRepositories() noexcept -> const std::vector<std::filesystem::path>& { @@ -43,6 +56,9 @@ class RemoteServeConfig : public RemoteExecutionConfig { } private: + // Server address of remote execution. + std::optional<ServerAddress> remote_address_{}; + // Known Git repositories to serve server. std::vector<std::filesystem::path> repositories_{}; }; |