aboutsummaryrefslogtreecommitdiff
path: root/zenserver/projectstore/remoteprojectstore.h
diff options
context:
space:
mode:
Diffstat (limited to 'zenserver/projectstore/remoteprojectstore.h')
-rw-r--r--zenserver/projectstore/remoteprojectstore.h111
1 files changed, 111 insertions, 0 deletions
diff --git a/zenserver/projectstore/remoteprojectstore.h b/zenserver/projectstore/remoteprojectstore.h
new file mode 100644
index 000000000..dcabaedd4
--- /dev/null
+++ b/zenserver/projectstore/remoteprojectstore.h
@@ -0,0 +1,111 @@
+// Copyright Epic Games, Inc. All Rights Reserved.
+
+#pragma once
+
+#include "projectstore.h"
+
+#include <unordered_set>
+
+namespace zen {
+
+class CidStore;
+class WorkerThreadPool;
+
+class RemoteProjectStore
+{
+public:
+ struct Result
+ {
+ int32_t ErrorCode{};
+ double ElapsedSeconds{};
+ std::string Reason;
+ std::string Text;
+ };
+
+ struct SaveResult : public Result
+ {
+ std::unordered_set<IoHash, IoHash::Hasher> Needs;
+ IoHash RawHash;
+ };
+
+ struct SaveAttachmentResult : public Result
+ {
+ };
+
+ struct SaveAttachmentsResult : public Result
+ {
+ };
+
+ struct LoadAttachmentResult : public Result
+ {
+ IoBuffer Bytes;
+ };
+
+ struct LoadContainerResult : public Result
+ {
+ CbObject ContainerObject;
+ };
+
+ struct LoadAttachmentsResult : public Result
+ {
+ std::vector<std::pair<IoHash, CompressedBuffer>> Chunks;
+ };
+
+ struct RemoteStoreInfo
+ {
+ bool CreateBlocks;
+ bool UseTempBlockFiles;
+ std::string Description;
+ };
+
+ virtual ~RemoteProjectStore() {}
+
+ virtual RemoteStoreInfo GetInfo() const = 0;
+
+ virtual SaveResult SaveContainer(const IoBuffer& Payload) = 0;
+ virtual SaveAttachmentResult SaveAttachment(const CompositeBuffer& Payload, const IoHash& RawHash) = 0;
+ virtual Result FinalizeContainer(const IoHash& RawHash) = 0;
+ virtual SaveAttachmentsResult SaveAttachments(const std::vector<SharedBuffer>& Payloads) = 0;
+
+ virtual LoadContainerResult LoadContainer() = 0;
+ virtual LoadAttachmentResult LoadAttachment(const IoHash& RawHash) = 0;
+ virtual LoadAttachmentsResult LoadAttachments(const std::vector<IoHash>& RawHashes) = 0;
+};
+
+struct RemoteStoreOptions
+{
+ size_t MaxBlockSize = 128u * 1024u * 1024u;
+ size_t MaxChunkEmbedSize = 1024u * 1024u;
+};
+
+RemoteProjectStore::LoadContainerResult BuildContainer(
+ CidStore& ChunkStore,
+ ProjectStore::Oplog& Oplog,
+ size_t MaxBlockSize,
+ size_t MaxChunkEmbedSize,
+ bool BuildBlocks,
+ const std::function<void(CompressedBuffer&&, const IoHash&)>& AsyncOnBlock,
+ const std::function<void(const IoHash&)>& OnLargeAttachment,
+ const std::function<void(const std::unordered_set<IoHash, IoHash::Hasher>)>& OnBlockChunks);
+
+RemoteProjectStore::Result SaveOplogContainer(ProjectStore::Oplog& Oplog,
+ const CbObject& ContainerObject,
+ const std::function<bool(const IoHash& RawHash)>& HasAttachment,
+ const std::function<void(const IoHash& BlockHash, std::vector<IoHash>&& Chunks)>& OnNeedBlock,
+ const std::function<void(const IoHash& RawHash)>& OnNeedAttachment);
+
+RemoteProjectStore::Result SaveOplog(CidStore& ChunkStore,
+ RemoteProjectStore& RemoteStore,
+ ProjectStore::Oplog& Oplog,
+ size_t MaxBlockSize,
+ size_t MaxChunkEmbedSize,
+ bool BuildBlocks,
+ bool UseTempBlocks,
+ bool ForceUpload);
+
+RemoteProjectStore::Result LoadOplog(CidStore& ChunkStore, RemoteProjectStore& RemoteStore, ProjectStore::Oplog& Oplog, bool ForceDownload);
+
+CompressedBuffer GenerateBlock(std::vector<SharedBuffer>&& Chunks);
+bool IterateBlock(IoBuffer&& CompressedBlock, std::function<void(CompressedBuffer&& Chunk, const IoHash& AttachmentHash)> Visitor);
+
+} // namespace zen