summaryrefslogtreecommitdiff
path: root/src/buildtool/execution_api/execution_service/execution_server.hpp
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2024-07-30 18:00:16 +0200
committerMaksim Denisov <denisov.maksim@huawei.com>2024-08-07 14:43:19 +0200
commit3188fb1a9b0e967969a3a7953923bcf94247bc09 (patch)
tree4b882a2b4f6eab13cca2c104b4c5ddeff1ea6797 /src/buildtool/execution_api/execution_service/execution_server.hpp
parent665147668bb8d8c712bffc078f4781bac9f30e99 (diff)
downloadjustbuild-3188fb1a9b0e967969a3a7953923bcf94247bc09.tar.gz
Use expected to return errors from ExecutionServiceImpl's methods
Diffstat (limited to 'src/buildtool/execution_api/execution_service/execution_server.hpp')
-rw-r--r--src/buildtool/execution_api/execution_service/execution_server.hpp21
1 files changed, 10 insertions, 11 deletions
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 <cstdint>
#include <optional>
#include <string>
-#include <utility>
+#include <variant> //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<::bazel_re::Action>,
- std::optional<std::string>>;
+ const noexcept -> expected<::bazel_re::Action, std::string>;
+
[[nodiscard]] auto GetCommand(::bazel_re::Action const& action)
- const noexcept -> std::pair<std::optional<::bazel_re::Command>,
- std::optional<std::string>>;
+ 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<IExecutionAction::Ptr>,
- std::optional<std::string>>;
+ -> expected<IExecutionAction::Ptr, std::string>;
[[nodiscard]] auto GetResponse(
::bazel_re::ExecuteRequest const* request,
IExecutionResponse::Ptr const& i_execution_response) const noexcept
- -> std::pair<std::optional<::bazel_re::ExecuteResponse>,
- std::optional<std::string>>;
+ -> 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<std::string>;
+ -> expected<std::monostate, std::string>;
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>;
+ std::string const& hash) const noexcept
+ -> expected<std::monostate, std::string>;
};
#endif