refactor(tvix/castore/directory): borrow in SimplePutter
This means we don't need to clone self in all implementations using SimplePutter. Change-Id: I11347028801c43c5cc9920c0a9edf47627096bce Reviewed-on: https://cl.tvl.fyi/c/depot/+/13262 Autosubmit: flokli <flokli@flokli.de> Reviewed-by: edef <edef@edef.eu> Tested-by: BuildkiteCI
This commit is contained in:
parent
54910b5bd8
commit
4415afa9de
4 changed files with 14 additions and 18 deletions
|
|
@ -319,11 +319,8 @@ impl DirectoryService for BigtableDirectoryService {
|
|||
}
|
||||
|
||||
#[instrument(skip_all, fields(instance_name=%self.instance_name))]
|
||||
fn put_multiple_start(&self) -> Box<(dyn DirectoryPutter + 'static)>
|
||||
where
|
||||
Self: Clone,
|
||||
{
|
||||
Box::new(SimplePutter::new(self.clone()))
|
||||
fn put_multiple_start(&self) -> Box<(dyn DirectoryPutter + '_)> {
|
||||
Box::new(SimplePutter::new(self))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ use crate::Error;
|
|||
/// which is useful when far does not support accessing intermediate directories (but near does).
|
||||
/// There is no negative cache.
|
||||
/// Inserts and listings are not implemented for now.
|
||||
#[derive(Clone)]
|
||||
pub struct Cache<DS1, DS2> {
|
||||
instance_name: String,
|
||||
near: DS1,
|
||||
|
|
@ -143,8 +142,8 @@ where
|
|||
}
|
||||
|
||||
#[instrument(skip_all)]
|
||||
fn put_multiple_start(&self) -> Box<(dyn DirectoryPutter + 'static)> {
|
||||
Box::new(SimplePutter::new((*self).clone()))
|
||||
fn put_multiple_start(&self) -> Box<(dyn DirectoryPutter + '_)> {
|
||||
Box::new(SimplePutter::new(self))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,11 +66,8 @@ impl DirectoryService for MemoryDirectoryService {
|
|||
}
|
||||
|
||||
#[instrument(skip_all, fields(instance_name=%self.instance_name))]
|
||||
fn put_multiple_start(&self) -> Box<(dyn DirectoryPutter + 'static)>
|
||||
where
|
||||
Self: Clone,
|
||||
{
|
||||
Box::new(SimplePutter::new(self.clone()))
|
||||
fn put_multiple_start(&self) -> Box<(dyn DirectoryPutter + '_)> {
|
||||
Box::new(SimplePutter::new(self))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,14 +10,17 @@ use tracing::warn;
|
|||
/// This is an implementation of DirectoryPutter that simply
|
||||
/// inserts individual Directory messages one by one, on close, after
|
||||
/// they successfully validated.
|
||||
pub struct SimplePutter<DS: DirectoryService> {
|
||||
directory_service: DS,
|
||||
pub struct SimplePutter<'a, DS> {
|
||||
directory_service: &'a DS,
|
||||
|
||||
directory_validator: Option<DirectoryGraph<LeavesToRootValidator>>,
|
||||
}
|
||||
|
||||
impl<DS: DirectoryService> SimplePutter<DS> {
|
||||
pub fn new(directory_service: DS) -> Self {
|
||||
impl<'a, DS> SimplePutter<'a, DS>
|
||||
where
|
||||
DS: DirectoryService,
|
||||
{
|
||||
pub fn new(directory_service: &'a DS) -> Self {
|
||||
Self {
|
||||
directory_service,
|
||||
directory_validator: Some(Default::default()),
|
||||
|
|
@ -26,7 +29,7 @@ impl<DS: DirectoryService> SimplePutter<DS> {
|
|||
}
|
||||
|
||||
#[async_trait]
|
||||
impl<DS: DirectoryService + 'static> DirectoryPutter for SimplePutter<DS> {
|
||||
impl<DS: DirectoryService + 'static> DirectoryPutter for SimplePutter<'_, DS> {
|
||||
#[instrument(level = "trace", skip_all, fields(directory.digest=%directory.digest()), err)]
|
||||
async fn put(&mut self, directory: Directory) -> Result<(), Error> {
|
||||
match self.directory_validator {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue