summaryrefslogtreecommitdiff
path: root/src/buildtool/serve_api/remote/source_tree_client.hpp
diff options
context:
space:
mode:
authorOliver Reiche <oliver.reiche@huawei.com>2024-06-27 17:44:34 +0200
committerOliver Reiche <oliver.reiche@huawei.com>2024-06-28 11:34:53 +0200
commit01d9abcfc85d974763c3a7f8fed998342d92a681 (patch)
tree105a887360a49dfa8bf942f48c5560d29b0dcd6e /src/buildtool/serve_api/remote/source_tree_client.hpp
parentf82ee35bff7363e6381d659b26773f260109e2ea (diff)
downloadjustbuild-01d9abcfc85d974763c3a7f8fed998342d92a681.tar.gz
Use (un)expected for serve API
Diffstat (limited to 'src/buildtool/serve_api/remote/source_tree_client.hpp')
-rw-r--r--src/buildtool/serve_api/remote/source_tree_client.hpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/buildtool/serve_api/remote/source_tree_client.hpp b/src/buildtool/serve_api/remote/source_tree_client.hpp
index 66d33005..802cb072 100644
--- a/src/buildtool/serve_api/remote/source_tree_client.hpp
+++ b/src/buildtool/serve_api/remote/source_tree_client.hpp
@@ -18,13 +18,14 @@
#include <memory>
#include <string>
#include <unordered_map>
-#include <variant>
#include "justbuild/just_serve/just_serve.grpc.pb.h"
#include "src/buildtool/common/remote/port.hpp"
#include "src/buildtool/common/remote/remote_common.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"
+#include "src/utils/cpp/expected.hpp"
/// Implements client side for SourceTree service defined in:
/// src/buildtool/serve_api/serve_service/just_serve.proto
@@ -33,7 +34,7 @@ class SourceTreeClient {
explicit SourceTreeClient(ServerAddress const& address) noexcept;
// An error + data union type
- using result_t = std::variant<bool, std::string>;
+ using result_t = expected<std::string, GitLookupError>;
/// \brief Retrieve the Git tree of a given commit, if known by the
/// endpoint. It is a fatal error if the commit is known to the endpoint but
@@ -41,9 +42,8 @@ class SourceTreeClient {
/// \param[in] commit_id Hash of the Git commit to look up.
/// \param[in] subdir Relative path of the tree inside commit.
/// \param[in] sync_tree Sync tree to the remote-execution endpoint.
- /// \returns An error + data union, where at index 0 we return a fatal flag,
- /// with false meaning non-fatal failure (commit or subtree not found), and
- /// at index 1 the tree identifier on success.
+ /// \returns The tree identifier on success or an unexpected error (fatal or
+ /// commit or subtree not found).
[[nodiscard]] auto ServeCommitTree(std::string const& commit_id,
std::string const& subdir,
bool sync_tree) const noexcept
@@ -58,9 +58,8 @@ class SourceTreeClient {
/// \param[in] resolve_symlinks Optional enum to state how symlinks in the
/// archive should be handled if the tree has to be actually computed.
/// \param[in] sync_tree Sync tree to the remote-execution endpoint.
- /// \returns An error + data union, where at index 0 we return a fatal flag,
- /// with false meaning non-fatal failure (content blob not found), and at
- /// index 1 the tree identifier on success.
+ /// \returns The tree identifier on success or an unexpected error (fatal or
+ /// content blob not found).
[[nodiscard]] auto ServeArchiveTree(
std::string const& content,
std::string const& archive_type,
@@ -74,9 +73,8 @@ class SourceTreeClient {
/// \param[in] distfiles Mapping from distfile names to content blob ids.
/// \param[in] sync_tree Sync tree and all ditfile blobs to the
/// remote-execution endpoint.
- /// \returns An error + data union, where at index 0 we return a fatal flag,
- /// with false meaning non-fatal failure (at least one distfile blob
- /// missing), and at index 1 the tree identifier on success.
+ /// \returns The tree identifier on success or an unexpected error (fatal or
+ /// at least one distfile blob missing).
[[nodiscard]] auto ServeDistdirTree(
std::shared_ptr<std::unordered_map<std::string, std::string>> const&
distfiles,