diff options
Diffstat (limited to 'src/buildtool/serve_api')
-rw-r--r-- | src/buildtool/serve_api/remote/TARGETS | 2 | ||||
-rw-r--r-- | src/buildtool/serve_api/remote/config.hpp | 20 | ||||
-rw-r--r-- | src/buildtool/serve_api/serve_service/TARGETS | 1 | ||||
-rw-r--r-- | src/buildtool/serve_api/serve_service/source_tree.cpp | 2 | ||||
-rw-r--r-- | src/buildtool/serve_api/serve_service/source_tree.hpp | 3 |
5 files changed, 23 insertions, 5 deletions
diff --git a/src/buildtool/serve_api/remote/TARGETS b/src/buildtool/serve_api/remote/TARGETS index 71f82b82..45114f57 100644 --- a/src/buildtool/serve_api/remote/TARGETS +++ b/src/buildtool/serve_api/remote/TARGETS @@ -2,7 +2,7 @@ { "type": ["@", "rules", "CC", "library"] , "name": ["config"] , "hdrs": ["config.hpp"] - , "deps": [["src/buildtool/execution_api/remote", "config"]] + , "deps": [["src/buildtool/common/remote", "remote_common"]] , "stage": ["src", "buildtool", "serve_api", "remote"] } , "serve_target_level_cache_client": 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_{}; }; diff --git a/src/buildtool/serve_api/serve_service/TARGETS b/src/buildtool/serve_api/serve_service/TARGETS index ec94ee76..dae08d35 100644 --- a/src/buildtool/serve_api/serve_service/TARGETS +++ b/src/buildtool/serve_api/serve_service/TARGETS @@ -14,6 +14,7 @@ , "proto": ["just_serve_proto"] , "deps": [ ["src/buildtool/logging", "logging"] + , ["src/buildtool/common/remote", "remote_common"] , ["src/buildtool/execution_api/common", "common"] , ["src/buildtool/execution_api/remote", "config"] ] diff --git a/src/buildtool/serve_api/serve_service/source_tree.cpp b/src/buildtool/serve_api/serve_service/source_tree.cpp index 8d91c2f5..69a7a607 100644 --- a/src/buildtool/serve_api/serve_service/source_tree.cpp +++ b/src/buildtool/serve_api/serve_service/source_tree.cpp @@ -25,7 +25,7 @@ #include "src/buildtool/storage/config.hpp" auto SourceTreeService::CreateExecutionApi( - std::optional<RemoteExecutionConfig::ServerAddress> const& address) + std::optional<ServerAddress> const& address) -> gsl::not_null<IExecutionApi::Ptr> { if (address) { ExecutionConfiguration config; diff --git a/src/buildtool/serve_api/serve_service/source_tree.hpp b/src/buildtool/serve_api/serve_service/source_tree.hpp index a1599508..0bdf48b8 100644 --- a/src/buildtool/serve_api/serve_service/source_tree.hpp +++ b/src/buildtool/serve_api/serve_service/source_tree.hpp @@ -23,6 +23,7 @@ #include "gsl/gsl" #include "justbuild/just_serve/just_serve.grpc.pb.h" +#include "src/buildtool/common/remote/remote_common.hpp" #include "src/buildtool/execution_api/common/execution_api.hpp" #include "src/buildtool/execution_api/remote/config.hpp" #include "src/buildtool/logging/logger.hpp" @@ -57,7 +58,7 @@ class SourceTreeService final CreateExecutionApi(std::nullopt)}; [[nodiscard]] static auto CreateExecutionApi( - std::optional<RemoteExecutionConfig::ServerAddress> const& address) + std::optional<ServerAddress> const& address) -> gsl::not_null<IExecutionApi::Ptr>; [[nodiscard]] static auto GetTreeFromCommit( |