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:
parent
b3d6e70909
commit
6d3f5b7eb4
2 changed files with 2 additions and 10 deletions
|
@ -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> {
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
Loading…
Reference in a new issue