summaryrefslogtreecommitdiff
path: root/src/buildtool/serve_api/remote/serve_api.hpp
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2025-01-21 14:36:55 +0100
committerMaksim Denisov <denisov.maksim@huawei.com>2025-01-23 16:50:37 +0100
commitb1934f3bc78c082f503210aca3e11da732406e79 (patch)
tree686d55be58babd52ce5352a54d2d740daeda790a /src/buildtool/serve_api/remote/serve_api.hpp
parent9628af44e244d98a9875586339086074b3d80941 (diff)
downloadjustbuild-b1934f3bc78c082f503210aca3e11da732406e79.tar.gz
ServeApi: Implement UploadTree
Diffstat (limited to 'src/buildtool/serve_api/remote/serve_api.hpp')
-rw-r--r--src/buildtool/serve_api/remote/serve_api.hpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/buildtool/serve_api/remote/serve_api.hpp b/src/buildtool/serve_api/remote/serve_api.hpp
index d6f15c3d..975e7a17 100644
--- a/src/buildtool/serve_api/remote/serve_api.hpp
+++ b/src/buildtool/serve_api/remote/serve_api.hpp
@@ -19,10 +19,13 @@
class ServeApi final {};
#else
+#include <filesystem>
#include <memory>
#include <optional>
#include <string>
#include <unordered_map>
+#include <utility>
+#include <variant>
#include <vector>
#include "gsl/gsl"
@@ -161,6 +164,16 @@ class ServeApi final {
return cc_.IsCompatible();
}
+ class UploadError;
+ /// \brief Upload a git tree from git repo to serve.
+ /// \param tree Tree to upload.
+ /// \param git_repo Git repository where the tree can be found.
+ /// \return std::monostate if the tree is available for this serve
+ /// instance after the call, or an unexpected UploadError on failure.
+ [[nodiscard]] auto UploadTree(ArtifactDigest const& tree,
+ std::filesystem::path const& git_repo)
+ const noexcept -> expected<std::monostate, UploadError>;
+
private:
// source tree service client
SourceTreeClient const stc_;
@@ -173,6 +186,29 @@ class ServeApi final {
ApiBundle const& apis_;
};
+class ServeApi::UploadError final {
+ public:
+ [[nodiscard]] auto Message() const& noexcept -> std::string const& {
+ return message_;
+ }
+
+ [[nodiscard]] auto Message() && noexcept -> std::string {
+ return std::move(message_);
+ }
+
+ [[nodiscard]] auto IsSyncError() const noexcept -> bool {
+ return is_sync_error_;
+ }
+
+ private:
+ friend ServeApi;
+ explicit UploadError(std::string message, bool is_sync_error) noexcept
+ : message_{std::move(message)}, is_sync_error_{is_sync_error} {}
+
+ std::string message_;
+ bool is_sync_error_;
+};
+
#endif // BOOTSTRAP_BUILD_TOOL
#endif // INCLUDED_SRC_BUILDTOOL_SERVE_API_REMOTE_SERVE_API_HPP