feat(tvix/store): add blobservice
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>
This commit is contained in:
parent
119aa43171
commit
b74ffda583
4 changed files with 146 additions and 0 deletions
20
tvix/store/src/blobservice/mod.rs
Normal file
20
tvix/store/src/blobservice/mod.rs
Normal file
|
|
@ -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>;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue