From 9ef2ffa9acdc19453c81696aa2ed4da7cb84078c Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Thu, 21 Sep 2023 18:19:58 +0200 Subject: 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. --- src/buildtool/serve_api/remote/config.hpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/buildtool/serve_api/remote/config.hpp') 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 #include -#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(inst.remote_address_ = ParseAddress(address)); + } + // Set the list of known repositories [[nodiscard]] static auto SetKnownRepositories( std::vector 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 { + return Instance().remote_address_; + } + // Repositories known to 'just serve' [[nodiscard]] static auto KnownRepositories() noexcept -> const std::vector& { @@ -43,6 +56,9 @@ class RemoteServeConfig : public RemoteExecutionConfig { } private: + // Server address of remote execution. + std::optional remote_address_{}; + // Known Git repositories to serve server. std::vector repositories_{}; }; -- cgit v1.2.3