refactor(tvix/store): impl Default for MemoryBlobService

Change-Id: I78a4cd86cb364b970e99393579808e773db5ceb2
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8237
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Autosubmit: flokli <flokli@flokli.de>
This commit is contained in:
Florian Klink 2023-03-10 12:21:52 +01:00 committed by clbot
parent b3d6e70909
commit 6d3f5b7eb4
2 changed files with 2 additions and 10 deletions

View file

@ -9,19 +9,11 @@ use crate::{proto, Error};
use super::BlobService; use super::BlobService;
#[derive(Clone)] #[derive(Clone, Default)]
pub struct MemoryBlobService { pub struct MemoryBlobService {
db: Arc<RwLock<HashMap<Vec<u8>, proto::BlobMeta>>>, db: Arc<RwLock<HashMap<Vec<u8>, proto::BlobMeta>>>,
} }
impl MemoryBlobService {
pub fn new() -> Self {
let db = Arc::new(RwLock::new(HashMap::default()));
Self { db }
}
}
impl BlobService for MemoryBlobService { impl BlobService for MemoryBlobService {
#[instrument(skip(self, req), fields(blob.digest=BASE64.encode(&req.digest)))] #[instrument(skip(self, req), fields(blob.digest=BASE64.encode(&req.digest)))]
fn stat(&self, req: &proto::StatBlobRequest) -> Result<Option<proto::BlobMeta>, Error> { fn stat(&self, req: &proto::StatBlobRequest) -> Result<Option<proto::BlobMeta>, Error> {

View file

@ -6,7 +6,7 @@ use crate::{
}; };
pub fn gen_blob_service() -> impl BlobService + Send + Sync + Clone + 'static { pub fn gen_blob_service() -> impl BlobService + Send + Sync + Clone + 'static {
MemoryBlobService::new() MemoryBlobService::default()
} }
pub fn gen_chunk_service() -> impl ChunkService + Clone { pub fn gen_chunk_service() -> impl ChunkService + Clone {