feat(tvix/castore): add composition module
Change-Id: I0868f3278db85ae5fe030089ee9033837bc08748 Signed-off-by: Yureka <tvl@yuka.dev> Reviewed-on: https://cl.tvl.fyi/c/depot/+/11853 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
This commit is contained in:
parent
64fd1d3e56
commit
1a6b6e3ef3
16 changed files with 747 additions and 51 deletions
|
|
@ -6,6 +6,7 @@ use tonic::async_trait;
|
|||
use tracing::instrument;
|
||||
|
||||
use super::{BlobReader, BlobService, BlobWriter};
|
||||
use crate::composition::{CompositionContext, ServiceBuilder};
|
||||
use crate::B3Digest;
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
|
|
@ -37,6 +38,22 @@ impl BlobService for MemoryBlobService {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize, Debug)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct MemoryBlobServiceConfig {}
|
||||
|
||||
#[async_trait]
|
||||
impl ServiceBuilder for MemoryBlobServiceConfig {
|
||||
type Output = dyn BlobService;
|
||||
async fn build<'a>(
|
||||
&'a self,
|
||||
_instance_name: &str,
|
||||
_context: &CompositionContext<dyn BlobService>,
|
||||
) -> Result<Arc<dyn BlobService>, Box<dyn std::error::Error + Send + Sync + 'static>> {
|
||||
Ok(Arc::new(MemoryBlobService::default()))
|
||||
}
|
||||
}
|
||||
|
||||
pub struct MemoryBlobWriter {
|
||||
db: Arc<RwLock<HashMap<B3Digest, Vec<u8>>>>,
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue