diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2024-06-20 12:50:02 +0200 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2024-06-25 13:59:48 +0200 |
commit | c2817da6d108acc38f17bf29900aa66d71337b34 (patch) | |
tree | 67a01416fe0ca645fc2957f6c33cbb987cded3a2 | |
parent | a08816fe82c04fbbc459d10b410efca27d260a20 (diff) | |
download | justbuild-c2817da6d108acc38f17bf29900aa66d71337b34.tar.gz |
Pass ApiBundle to ServerImpl
6 files changed, 16 insertions, 12 deletions
diff --git a/src/buildtool/execution_api/execution_service/TARGETS b/src/buildtool/execution_api/execution_service/TARGETS index 7719b7d3..7f2b5e1c 100644 --- a/src/buildtool/execution_api/execution_service/TARGETS +++ b/src/buildtool/execution_api/execution_service/TARGETS @@ -7,7 +7,7 @@ , "stage": ["src", "buildtool", "execution_api", "execution_service"] , "deps": [ ["@", "gsl", "", "gsl"] - , ["src/buildtool/execution_api/local", "local"] + , ["src/buildtool/execution_api/common", "common"] , ["src/buildtool/logging", "logging"] , ["src/buildtool/common", "bazel_types"] , ["src/buildtool/storage", "storage"] @@ -38,7 +38,6 @@ ] , "private-deps": [ ["src/buildtool/storage", "storage"] - , ["src/buildtool/execution_api/local", "local"] , ["src/buildtool/logging", "log_level"] , ["src/utils/cpp", "verify_hash"] ] @@ -71,6 +70,7 @@ , "hdrs": ["server_implementation.hpp"] , "srcs": ["server_implementation.cpp"] , "stage": ["src", "buildtool", "execution_api", "execution_service"] + , "deps": [["src/buildtool/execution_api/common", "api_bundle"]] , "private-deps": [ "execution_server" , "ac_server" @@ -83,7 +83,6 @@ , ["src/buildtool/logging", "logging"] , ["src/buildtool/auth", "auth"] , ["@", "json", "", "json"] - , ["src/buildtool/execution_api/local", "local"] , ["@", "grpc", "", "grpc++"] , ["src/buildtool/execution_api/remote", "config"] , ["@", "fmt", "", "fmt"] @@ -110,7 +109,6 @@ , ["src/utils/cpp", "tmp_dir"] , ["@", "fmt", "", "fmt"] , ["src/buildtool/storage", "storage"] - , ["src/buildtool/execution_api/local", "local"] , ["src/utils/cpp", "verify_hash"] ] } diff --git a/src/buildtool/execution_api/execution_service/execution_server.hpp b/src/buildtool/execution_api/execution_service/execution_server.hpp index 198b5f14..48f50624 100644 --- a/src/buildtool/execution_api/execution_service/execution_server.hpp +++ b/src/buildtool/execution_api/execution_service/execution_server.hpp @@ -18,13 +18,15 @@ #include "build/bazel/remote/execution/v2/remote_execution.grpc.pb.h" #include "gsl/gsl" #include "src/buildtool/common/bazel_types.hpp" -#include "src/buildtool/execution_api/local/local_api.hpp" +#include "src/buildtool/execution_api/common/execution_api.hpp" #include "src/buildtool/logging/logger.hpp" #include "src/buildtool/storage/storage.hpp" class ExecutionServiceImpl final : public bazel_re::Execution::Service { public: - ExecutionServiceImpl() = default; + explicit ExecutionServiceImpl( + gsl::not_null<IExecutionApi*> const& local_api) noexcept + : api_{local_api} {} // Execute an action remotely. // // In order to execute an action, the client must first upload all of the @@ -109,7 +111,7 @@ class ExecutionServiceImpl final : public bazel_re::Execution::Service { private: gsl::not_null<Storage const*> storage_ = &Storage::Instance(); - IExecutionApi::Ptr api_{new LocalApi()}; + gsl::not_null<IExecutionApi*> const api_; Logger logger_{"execution-service"}; [[nodiscard]] auto GetAction(::bazel_re::ExecuteRequest const* request) diff --git a/src/buildtool/execution_api/execution_service/server_implementation.cpp b/src/buildtool/execution_api/execution_service/server_implementation.cpp index 57a03133..7a9745db 100644 --- a/src/buildtool/execution_api/execution_service/server_implementation.cpp +++ b/src/buildtool/execution_api/execution_service/server_implementation.cpp @@ -54,8 +54,8 @@ auto TryWrite(std::string const& file, T const& content) noexcept -> bool { } } // namespace -auto ServerImpl::Run() -> bool { - ExecutionServiceImpl es{}; +auto ServerImpl::Run(ApiBundle const& apis) -> bool { + ExecutionServiceImpl es{&*apis.local}; ActionCacheServiceImpl ac{}; CASServiceImpl cas{}; BytestreamServiceImpl b{}; diff --git a/src/buildtool/execution_api/execution_service/server_implementation.hpp b/src/buildtool/execution_api/execution_service/server_implementation.hpp index 4570a66c..7df517ad 100644 --- a/src/buildtool/execution_api/execution_service/server_implementation.hpp +++ b/src/buildtool/execution_api/execution_service/server_implementation.hpp @@ -18,6 +18,8 @@ #include <fstream> #include <string> +#include "src/buildtool/execution_api/common/api_bundle.hpp" + class ServerImpl { public: ServerImpl() noexcept = default; @@ -45,7 +47,7 @@ class ServerImpl { ServerImpl(ServerImpl&&) noexcept = delete; auto operator=(ServerImpl&&) noexcept -> ServerImpl& = delete; - auto Run() -> bool; + auto Run(ApiBundle const& apis) -> bool; ~ServerImpl() = default; private: diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp index 480dfbf4..f107e38f 100644 --- a/src/buildtool/main/main.cpp +++ b/src/buildtool/main/main.cpp @@ -826,7 +826,9 @@ auto main(int argc, char* argv[]) -> int { if (arguments.cmd == SubCommand::kExecute) { SetupExecutionServiceConfig(arguments.service); - if (!ServerImpl::Instance().Run()) { + ApiBundle const exec_apis{std::nullopt, + RemoteExecutionConfig::RemoteAddress()}; + if (!ServerImpl::Instance().Run(exec_apis)) { return kExitFailure; } return kExitSuccess; diff --git a/src/buildtool/serve_api/serve_service/serve_server_implementation.cpp b/src/buildtool/serve_api/serve_service/serve_server_implementation.cpp index a2ea32c3..c28a2a71 100644 --- a/src/buildtool/serve_api/serve_service/serve_server_implementation.cpp +++ b/src/buildtool/serve_api/serve_service/serve_server_implementation.cpp @@ -118,7 +118,7 @@ auto ServeServerImpl::Run(RemoteServeConfig const& serve_config, // the user has not given any remote-execution endpoint // so we start a "just-execute instance" on the same process - [[maybe_unused]] ExecutionServiceImpl es{}; + [[maybe_unused]] ExecutionServiceImpl es{&*apis.local}; [[maybe_unused]] ActionCacheServiceImpl ac{}; [[maybe_unused]] CASServiceImpl cas{}; [[maybe_unused]] BytestreamServiceImpl b{}; |