about summary refs log tree commit diff
path: root/tvix/store/src/blobservice/mod.rs
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-02-12T11·03+0100
committerflokli <flokli@flokli.de>2023-03-06T15·32+0000
commitb74ffda583d40db8b94b58418f70430687b2eaf0 (patch)
tree767fdf6ec400b4b3650c892c7f3cd0646f760271 /tvix/store/src/blobservice/mod.rs
parent119aa43171c2e2c654d513ea2f2ee740f962a398 (diff)
feat(tvix/store): add blobservice r/5894
This adds a BlobService trait, and an implementation for it using sled,
and one using a HashMap.

Change-Id: Id6bc1b629195d0b26fc503bd7d2dc9e43c41c317
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8087
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'tvix/store/src/blobservice/mod.rs')
-rw-r--r--tvix/store/src/blobservice/mod.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/tvix/store/src/blobservice/mod.rs b/tvix/store/src/blobservice/mod.rs
new file mode 100644
index 000000000000..53e941795e7e
--- /dev/null
+++ b/tvix/store/src/blobservice/mod.rs
@@ -0,0 +1,20 @@
+use crate::{proto, Error};
+
+mod memory;
+mod sled;
+
+pub use self::memory::MemoryBlobService;
+pub use self::sled::SledBlobService;
+
+/// The base trait all BlobService services need to implement.
+/// It provides information about how a blob is chunked,
+/// and allows creating new blobs by creating a BlobMeta (referring to chunks
+/// in a [crate::chunkservice::ChunkService]).
+pub trait BlobService {
+    /// Retrieve chunking information for a given blob
+    fn stat(&self, req: &proto::StatBlobRequest) -> Result<Option<proto::BlobMeta>, Error>;
+
+    /// Insert chunking information for a given blob.
+    /// Implementations SHOULD make sure chunks referred do exist.
+    fn put(&self, blob_digest: &[u8], blob_meta: proto::BlobMeta) -> Result<(), Error>;
+}