From a5f048e3b2504959994cc9545a70fde01b70d99a Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Mon, 15 Jul 2024 10:19:16 +0200 Subject: Make OperationCache a general class, not singleton As it is used by just execute only, instantiate it inside the ExecutionServer, which reads and writes to the cache map, and pass a const ref to OperationsServer, which only queries. --- .../execution_service/execution_server.hpp | 25 ++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src/buildtool/execution_api/execution_service/execution_server.hpp') diff --git a/src/buildtool/execution_api/execution_service/execution_server.hpp b/src/buildtool/execution_api/execution_service/execution_server.hpp index cc72a1e3..7107ed45 100644 --- a/src/buildtool/execution_api/execution_service/execution_server.hpp +++ b/src/buildtool/execution_api/execution_service/execution_server.hpp @@ -15,10 +15,16 @@ #ifndef EXECUTION_SERVER_HPP #define EXECUTION_SERVER_HPP +#include +#include +#include +#include + #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/common/execution_api.hpp" +#include "src/buildtool/execution_api/execution_service/operation_cache.hpp" #include "src/buildtool/logging/logger.hpp" #include "src/buildtool/storage/config.hpp" #include "src/buildtool/storage/storage.hpp" @@ -28,10 +34,19 @@ class ExecutionServiceImpl final : public bazel_re::Execution::Service { explicit ExecutionServiceImpl( gsl::not_null const& storage_config, gsl::not_null const& storage, - gsl::not_null const& local_api) noexcept + gsl::not_null const& local_api, + std::optional op_exponent) noexcept : storage_config_{*storage_config}, storage_{*storage}, - api_{*local_api} {} + api_{*local_api} { + if (op_exponent) { + op_cache_.SetExponent(*op_exponent); + } + } + + [[nodiscard]] auto GetOpCache() const noexcept -> OperationCache const& { + return op_cache_; + } // Execute an action remotely. // @@ -119,6 +134,7 @@ class ExecutionServiceImpl final : public bazel_re::Execution::Service { StorageConfig const& storage_config_; Storage const& storage_; IExecutionApi const& api_; + OperationCache op_cache_; Logger logger_{"execution-service"}; [[nodiscard]] auto GetAction(::bazel_re::ExecuteRequest const* request) @@ -147,6 +163,11 @@ class ExecutionServiceImpl final : public bazel_re::Execution::Service { ::bazel_re::Action const& action) const noexcept -> std::optional; + void WriteResponse( + ::bazel_re::ExecuteResponse const& execute_response, + ::grpc::ServerWriter<::google::longrunning::Operation>* writer, + ::google::longrunning::Operation* op) noexcept; + [[nodiscard]] auto AddResult( ::bazel_re::ExecuteResponse* response, IExecutionResponse::Ptr const& i_execution_response, -- cgit v1.2.3