From 3188fb1a9b0e967969a3a7953923bcf94247bc09 Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Tue, 30 Jul 2024 18:00:16 +0200 Subject: Use expected to return errors from ExecutionServiceImpl's methods --- .../execution_service/execution_server.hpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 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 e09f028b..9ffaa9a7 100644 --- a/src/buildtool/execution_api/execution_service/execution_server.hpp +++ b/src/buildtool/execution_api/execution_service/execution_server.hpp @@ -18,7 +18,7 @@ #include #include #include -#include +#include //std::monostate #include "build/bazel/remote/execution/v2/remote_execution.grpc.pb.h" #include "gsl/gsl" @@ -29,6 +29,7 @@ #include "src/buildtool/logging/logger.hpp" #include "src/buildtool/storage/config.hpp" #include "src/buildtool/storage/storage.hpp" +#include "src/utils/cpp/expected.hpp" class ExecutionServiceImpl final : public bazel_re::Execution::Service { public: @@ -138,30 +139,27 @@ class ExecutionServiceImpl final : public bazel_re::Execution::Service { Logger logger_{"execution-service"}; [[nodiscard]] auto GetAction(::bazel_re::ExecuteRequest const* request) - const noexcept -> std::pair, - std::optional>; + const noexcept -> expected<::bazel_re::Action, std::string>; + [[nodiscard]] auto GetCommand(::bazel_re::Action const& action) - const noexcept -> std::pair, - std::optional>; + const noexcept -> expected<::bazel_re::Command, std::string>; [[nodiscard]] auto GetIExecutionAction( ::bazel_re::ExecuteRequest const* request, ::bazel_re::Action const& action) const - -> std::pair, - std::optional>; + -> expected; [[nodiscard]] auto GetResponse( ::bazel_re::ExecuteRequest const* request, IExecutionResponse::Ptr const& i_execution_response) const noexcept - -> std::pair, - std::optional>; + -> expected<::bazel_re::ExecuteResponse, std::string>; [[nodiscard]] auto StoreActionResult( ::bazel_re::ExecuteRequest const* request, IExecutionResponse::Ptr const& i_execution_response, ::bazel_re::ExecuteResponse const& execute_response, ::bazel_re::Action const& action) const noexcept - -> std::optional; + -> expected; void WriteResponse( ::bazel_re::ExecuteResponse const& execute_response, @@ -171,7 +169,8 @@ class ExecutionServiceImpl final : public bazel_re::Execution::Service { [[nodiscard]] auto AddResult( ::bazel_re::ExecuteResponse* response, IExecutionResponse::Ptr const& i_execution_response, - std::string const& hash) const noexcept -> std::optional; + std::string const& hash) const noexcept + -> expected; }; #endif -- cgit v1.2.3