diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/main/main.cpp | 10 | ||||
-rw-r--r-- | src/buildtool/serve_api/remote/TARGETS | 17 | ||||
-rw-r--r-- | src/buildtool/serve_api/remote/configuration_client.cpp | 13 | ||||
-rw-r--r-- | src/buildtool/serve_api/remote/configuration_client.hpp | 16 | ||||
-rw-r--r-- | src/buildtool/serve_api/remote/serve_api.hpp | 21 | ||||
-rw-r--r-- | src/buildtool/serve_api/remote/source_tree_client.cpp | 7 | ||||
-rw-r--r-- | src/buildtool/serve_api/remote/source_tree_client.hpp | 8 | ||||
-rw-r--r-- | src/buildtool/serve_api/remote/target_client.cpp | 21 | ||||
-rw-r--r-- | src/buildtool/serve_api/remote/target_client.hpp | 11 | ||||
-rw-r--r-- | src/other_tools/just_mr/fetch.cpp | 3 | ||||
-rw-r--r-- | src/other_tools/just_mr/setup.cpp | 3 |
11 files changed, 74 insertions, 56 deletions
diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp index 7ea42821..27dd7d24 100644 --- a/src/buildtool/main/main.cpp +++ b/src/buildtool/main/main.cpp @@ -890,8 +890,10 @@ auto main(int argc, char* argv[]) -> int { ApiBundle const serve_apis{&local_context, &remote_context, /*repo_config=*/nullptr}; - auto serve = - ServeApi::Create(*serve_config, &storage, &serve_apis); + auto serve = ServeApi::Create(*serve_config, + &local_context, + &remote_context, + &serve_apis); bool with_execute = not remote_exec_config->remote_address.has_value(); @@ -1021,8 +1023,8 @@ auto main(int argc, char* argv[]) -> int { DetermineRoots(&repo_config, arguments.common, arguments.analysis); #ifndef BOOTSTRAP_BUILD_TOOL - std::optional<ServeApi> serve = - ServeApi::Create(*serve_config, &storage, &main_apis); + std::optional<ServeApi> serve = ServeApi::Create( + *serve_config, &local_context, &remote_context, &main_apis); #else std::optional<ServeApi> serve; #endif // BOOTSTRAP_BUILD_TOOL diff --git a/src/buildtool/serve_api/remote/TARGETS b/src/buildtool/serve_api/remote/TARGETS index bd0f8646..fe8bfcda 100644 --- a/src/buildtool/serve_api/remote/TARGETS +++ b/src/buildtool/serve_api/remote/TARGETS @@ -17,12 +17,11 @@ , "srcs": ["source_tree_client.cpp"] , "deps": [ ["@", "gsl", "", "gsl"] - , ["src/buildtool/auth", "auth"] - , ["src/buildtool/common/remote", "port"] + , ["src/buildtool/common/remote", "remote_common"] + , ["src/buildtool/execution_api/remote", "context"] , ["src/buildtool/file_system", "git_types"] , ["src/buildtool/file_system/symlinks_map", "pragma_special"] , ["src/buildtool/logging", "logging"] - , ["src/buildtool/common/remote", "remote_common"] ] , "proto": [["src/buildtool/serve_api/serve_service", "just_serve_proto"]] , "stage": ["src", "buildtool", "serve_api", "remote"] @@ -43,8 +42,9 @@ , ["src/buildtool/file_system", "git_types"] , ["src/buildtool/file_system/symlinks_map", "pragma_special"] , ["src/buildtool/execution_api/common", "api_bundle"] + , ["src/buildtool/execution_api/local", "context"] + , ["src/buildtool/execution_api/remote", "context"] , ["src/utils/cpp", "expected"] - , ["src/buildtool/storage", "storage"] , "source_tree_client" , "target_client" , "configuration_client" @@ -64,6 +64,8 @@ , ["src/buildtool/common", "common"] , ["src/buildtool/logging", "logging"] , ["src/buildtool/execution_api/common", "api_bundle"] + , ["src/buildtool/execution_api/remote", "config"] + , ["src/buildtool/execution_api/remote", "context"] , ["src/buildtool/storage", "storage"] ] , "proto": [["src/buildtool/serve_api/serve_service", "just_serve_proto"]] @@ -71,7 +73,6 @@ , "private-deps": [ ["src/buildtool/common/remote", "client_common"] , ["src/buildtool/common", "bazel_types"] - , ["src/buildtool/execution_api/remote", "config"] , ["@", "fmt", "", "fmt"] , ["@", "json", "", "json"] ] @@ -83,11 +84,9 @@ , "srcs": ["configuration_client.cpp"] , "deps": [ ["@", "gsl", "", "gsl"] - , ["src/buildtool/auth", "auth"] - , ["src/buildtool/common/remote", "port"] , ["src/buildtool/execution_api/remote", "config"] + , ["src/buildtool/execution_api/remote", "context"] , ["src/buildtool/logging", "logging"] - , ["src/buildtool/common/remote", "client_common"] , ["src/buildtool/common/remote", "remote_common"] ] , "proto": [["src/buildtool/serve_api/serve_service", "just_serve_proto"]] @@ -95,7 +94,7 @@ , "private-deps": [ ["@", "json", "", "json"] , ["src/buildtool/logging", "log_level"] - , ["src/buildtool/serve_api/remote", "config"] + , ["src/buildtool/common/remote", "client_common"] ] } } diff --git a/src/buildtool/serve_api/remote/configuration_client.cpp b/src/buildtool/serve_api/remote/configuration_client.cpp index 07fddf12..fdc9952b 100644 --- a/src/buildtool/serve_api/remote/configuration_client.cpp +++ b/src/buildtool/serve_api/remote/configuration_client.cpp @@ -20,8 +20,19 @@ #include <optional> #include "nlohmann/json.hpp" +#include "src/buildtool/common/remote/client_common.hpp" #include "src/buildtool/logging/log_level.hpp" -#include "src/buildtool/serve_api/remote/config.hpp" + +ConfigurationClient::ConfigurationClient( + ServerAddress address, + gsl::not_null<RemoteContext const*> const& remote_context) noexcept + : client_serve_address_{std::move(address)}, + remote_config_{*remote_context->exec_config} { + stub_ = justbuild::just_serve::Configuration::NewStub( + CreateChannelWithCredentials(client_serve_address_.host, + client_serve_address_.port, + remote_context->auth)); +} auto ConfigurationClient::CheckServeRemoteExecution() const noexcept -> bool { auto const client_remote_address = remote_config_.remote_address; diff --git a/src/buildtool/serve_api/remote/configuration_client.hpp b/src/buildtool/serve_api/remote/configuration_client.hpp index 3ae6d1e6..92f8c2df 100644 --- a/src/buildtool/serve_api/remote/configuration_client.hpp +++ b/src/buildtool/serve_api/remote/configuration_client.hpp @@ -23,11 +23,9 @@ #include "gsl/gsl" #include "justbuild/just_serve/just_serve.grpc.pb.h" -#include "src/buildtool/auth/authentication.hpp" -#include "src/buildtool/common/remote/client_common.hpp" -#include "src/buildtool/common/remote/port.hpp" #include "src/buildtool/common/remote/remote_common.hpp" #include "src/buildtool/execution_api/remote/config.hpp" +#include "src/buildtool/execution_api/remote/context.hpp" #include "src/buildtool/logging/logger.hpp" /// Implements client side for Configuration service defined in: @@ -36,15 +34,7 @@ class ConfigurationClient { public: explicit ConfigurationClient( ServerAddress address, - gsl::not_null<Auth const*> const& auth, - gsl::not_null<RemoteExecutionConfig const*> const& - remote_config) noexcept - : client_serve_address_{std::move(address)}, - stub_{justbuild::just_serve::Configuration::NewStub( - CreateChannelWithCredentials(client_serve_address_.host, - client_serve_address_.port, - auth))}, - remote_config_{*remote_config} {} + gsl::not_null<RemoteContext const*> const& remote_context) noexcept; [[nodiscard]] auto CheckServeRemoteExecution() const noexcept -> bool; @@ -52,8 +42,8 @@ class ConfigurationClient { private: ServerAddress const client_serve_address_; - std::unique_ptr<justbuild::just_serve::Configuration::Stub> stub_; RemoteExecutionConfig const& remote_config_; + std::unique_ptr<justbuild::just_serve::Configuration::Stub> stub_; Logger logger_{"RemoteConfigurationClient"}; }; diff --git a/src/buildtool/serve_api/remote/serve_api.hpp b/src/buildtool/serve_api/remote/serve_api.hpp index 54d06eed..f3861eb7 100644 --- a/src/buildtool/serve_api/remote/serve_api.hpp +++ b/src/buildtool/serve_api/remote/serve_api.hpp @@ -30,23 +30,25 @@ class ServeApi final {}; #include "src/buildtool/common/remote/port.hpp" #include "src/buildtool/common/remote/remote_common.hpp" #include "src/buildtool/execution_api/common/api_bundle.hpp" +#include "src/buildtool/execution_api/local/context.hpp" +#include "src/buildtool/execution_api/remote/context.hpp" #include "src/buildtool/file_system/git_types.hpp" #include "src/buildtool/file_system/symlinks_map/pragma_special.hpp" #include "src/buildtool/serve_api/remote/config.hpp" #include "src/buildtool/serve_api/remote/configuration_client.hpp" #include "src/buildtool/serve_api/remote/source_tree_client.hpp" #include "src/buildtool/serve_api/remote/target_client.hpp" -#include "src/buildtool/storage/storage.hpp" #include "src/utils/cpp/expected.hpp" class ServeApi final { public: explicit ServeApi(ServerAddress const& address, - gsl::not_null<Storage const*> const& storage, + gsl::not_null<LocalContext const*> const& local_context, + gsl::not_null<RemoteContext const*> const& remote_context, gsl::not_null<ApiBundle const*> const& apis) noexcept - : stc_{address, &apis->auth}, - tc_{address, storage, apis}, - cc_{address, &apis->auth, &apis->remote_config} {} + : stc_{address, remote_context}, + tc_{address, local_context->storage, remote_context, apis}, + cc_{address, remote_context} {} ~ServeApi() noexcept = default; ServeApi(ServeApi const&) = delete; @@ -56,12 +58,15 @@ class ServeApi final { [[nodiscard]] static auto Create( RemoteServeConfig const& serve_config, - gsl::not_null<Storage const*> const& storage, + gsl::not_null<LocalContext const*> const& local_context, + gsl::not_null<RemoteContext const*> const& remote_context, gsl::not_null<ApiBundle const*> const& apis) noexcept -> std::optional<ServeApi> { if (serve_config.remote_address) { - return std::make_optional<ServeApi>( - *serve_config.remote_address, storage, apis); + return std::make_optional<ServeApi>(*serve_config.remote_address, + local_context, + remote_context, + apis); } return std::nullopt; } diff --git a/src/buildtool/serve_api/remote/source_tree_client.cpp b/src/buildtool/serve_api/remote/source_tree_client.cpp index 7a922671..994fcc21 100644 --- a/src/buildtool/serve_api/remote/source_tree_client.cpp +++ b/src/buildtool/serve_api/remote/source_tree_client.cpp @@ -61,9 +61,10 @@ auto PragmaSpecialToSymlinksResolve( SourceTreeClient::SourceTreeClient( ServerAddress const& address, - gsl::not_null<Auth const*> const& auth) noexcept { - stub_ = justbuild::just_serve::SourceTree::NewStub( - CreateChannelWithCredentials(address.host, address.port, auth)); + gsl::not_null<RemoteContext const*> const& remote_context) noexcept { + stub_ = + justbuild::just_serve::SourceTree::NewStub(CreateChannelWithCredentials( + address.host, address.port, remote_context->auth)); } auto SourceTreeClient::ServeCommitTree(std::string const& commit_id, diff --git a/src/buildtool/serve_api/remote/source_tree_client.hpp b/src/buildtool/serve_api/remote/source_tree_client.hpp index e5001029..c849eeb3 100644 --- a/src/buildtool/serve_api/remote/source_tree_client.hpp +++ b/src/buildtool/serve_api/remote/source_tree_client.hpp @@ -21,9 +21,8 @@ #include "gsl/gsl" #include "justbuild/just_serve/just_serve.grpc.pb.h" -#include "src/buildtool/auth/authentication.hpp" -#include "src/buildtool/common/remote/port.hpp" #include "src/buildtool/common/remote/remote_common.hpp" +#include "src/buildtool/execution_api/remote/context.hpp" #include "src/buildtool/file_system/git_types.hpp" #include "src/buildtool/file_system/symlinks_map/pragma_special.hpp" #include "src/buildtool/logging/logger.hpp" @@ -33,8 +32,9 @@ /// src/buildtool/serve_api/serve_service/just_serve.proto class SourceTreeClient { public: - explicit SourceTreeClient(ServerAddress const& address, - gsl::not_null<Auth const*> const& auth) noexcept; + explicit SourceTreeClient( + ServerAddress const& address, + gsl::not_null<RemoteContext const*> const& remote_context) noexcept; // An error + data union type using result_t = expected<std::string, GitLookupError>; diff --git a/src/buildtool/serve_api/remote/target_client.cpp b/src/buildtool/serve_api/remote/target_client.cpp index 1d3a385b..0cb47ffd 100644 --- a/src/buildtool/serve_api/remote/target_client.cpp +++ b/src/buildtool/serve_api/remote/target_client.cpp @@ -23,15 +23,18 @@ #include "nlohmann/json.hpp" #include "src/buildtool/common/bazel_types.hpp" #include "src/buildtool/common/remote/client_common.hpp" -#include "src/buildtool/execution_api/remote/config.hpp" #include "src/buildtool/logging/log_level.hpp" -TargetClient::TargetClient(ServerAddress const& address, - gsl::not_null<Storage const*> const& storage, - gsl::not_null<ApiBundle const*> const& apis) noexcept - : storage_{*storage}, apis_{*apis} { - stub_ = justbuild::just_serve::Target::NewStub( - CreateChannelWithCredentials(address.host, address.port, &apis->auth)); +TargetClient::TargetClient( + ServerAddress const& address, + gsl::not_null<Storage const*> const& storage, + gsl::not_null<RemoteContext const*> const& remote_context, + gsl::not_null<ApiBundle const*> const& apis) noexcept + : storage_{*storage}, + exec_config_{*remote_context->exec_config}, + apis_{*apis} { + stub_ = justbuild::just_serve::Target::NewStub(CreateChannelWithCredentials( + address.host, address.port, remote_context->auth)); } auto TargetClient::ServeTarget(const TargetCacheKey& key, @@ -60,7 +63,7 @@ auto TargetClient::ServeTarget(const TargetCacheKey& key, request.mutable_target_cache_key_id()->CopyFrom(key_dgst); // add execution properties to request - for (auto const& [k, v] : apis_.remote_config.platform_properties) { + for (auto const& [k, v] : exec_config_.platform_properties) { auto* prop = request.add_execution_properties(); prop->set_name(k); prop->set_value(v); @@ -70,7 +73,7 @@ auto TargetClient::ServeTarget(const TargetCacheKey& key, // to remote cas auto dispatch_list = nlohmann::json::array(); try { - for (auto const& [props, endpoint] : apis_.remote_config.dispatch) { + for (auto const& [props, endpoint] : exec_config_.dispatch) { auto entry = nlohmann::json::array(); entry.push_back(nlohmann::json(props)); entry.push_back(endpoint.ToJson()); diff --git a/src/buildtool/serve_api/remote/target_client.hpp b/src/buildtool/serve_api/remote/target_client.hpp index f8f51987..e6ca07ff 100644 --- a/src/buildtool/serve_api/remote/target_client.hpp +++ b/src/buildtool/serve_api/remote/target_client.hpp @@ -29,6 +29,8 @@ #include "src/buildtool/common/remote/port.hpp" #include "src/buildtool/common/remote/remote_common.hpp" #include "src/buildtool/execution_api/common/api_bundle.hpp" +#include "src/buildtool/execution_api/remote/config.hpp" +#include "src/buildtool/execution_api/remote/context.hpp" #include "src/buildtool/logging/logger.hpp" #include "src/buildtool/storage/storage.hpp" #include "src/buildtool/storage/target_cache_entry.hpp" @@ -53,9 +55,11 @@ using serve_target_result_t = /// src/buildtool/serve_api/serve_service/just_serve.proto class TargetClient { public: - explicit TargetClient(ServerAddress const& address, - gsl::not_null<Storage const*> const& storage, - gsl::not_null<ApiBundle const*> const& apis) noexcept; + explicit TargetClient( + ServerAddress const& address, + gsl::not_null<Storage const*> const& storage, + gsl::not_null<RemoteContext const*> const& remote_context, + gsl::not_null<ApiBundle const*> const& apis) noexcept; /// \brief Retrieve the pair of TargetCacheEntry and ObjectInfo associated /// to the given key. @@ -90,6 +94,7 @@ class TargetClient { private: Storage const& storage_; + RemoteExecutionConfig const& exec_config_; ApiBundle const& apis_; std::unique_ptr<justbuild::just_serve::Target::Stub> stub_; Logger logger_{"RemoteTargetClient"}; diff --git a/src/other_tools/just_mr/fetch.cpp b/src/other_tools/just_mr/fetch.cpp index 8da3647b..088c9ace 100644 --- a/src/other_tools/just_mr/fetch.cpp +++ b/src/other_tools/just_mr/fetch.cpp @@ -454,7 +454,8 @@ auto MultiRepoFetch(std::shared_ptr<Configuration> const& config, return kExitConfigError; } - auto serve = ServeApi::Create(*serve_config, &storage, &apis); + auto serve = + ServeApi::Create(*serve_config, &local_context, &remote_context, &apis); // check configuration of the serve endpoint provided if (serve) { // if we have a remote endpoint explicitly given by the user, it must diff --git a/src/other_tools/just_mr/setup.cpp b/src/other_tools/just_mr/setup.cpp index 88bd0ca5..9f9e09bd 100644 --- a/src/other_tools/just_mr/setup.cpp +++ b/src/other_tools/just_mr/setup.cpp @@ -175,7 +175,8 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config, return std::nullopt; } - auto serve = ServeApi::Create(*serve_config, &storage, &apis); + auto serve = + ServeApi::Create(*serve_config, &local_context, &remote_context, &apis); // check configuration of the serve endpoint provided if (serve) { |