refactor(tvix/store): use Arc instead of Box
This allows us to blob services without closing them before putting them in a box. We currently need to use Arc<_>, not Rc<_>, because the GRPC wrappers require Sync. Change-Id: I679c5f06b62304f5b0456cfefe25a0a881de7c84 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8738 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI Autosubmit: flokli <flokli@flokli.de>
This commit is contained in:
parent
7725eb53ad
commit
aa7bdc1199
13 changed files with 132 additions and 108 deletions
|
|
@ -1,6 +1,7 @@
|
|||
use crate::blobservice::BlobService;
|
||||
use crate::directoryservice::DirectoryService;
|
||||
use crate::{directoryservice::DirectoryPutter, proto};
|
||||
use std::sync::Arc;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
fmt::Debug,
|
||||
|
|
@ -57,7 +58,7 @@ impl From<super::Error> for Error {
|
|||
// It assumes the caller adds returned nodes to the directories it assembles.
|
||||
#[instrument(skip_all, fields(entry.file_type=?&entry.file_type(),entry.path=?entry.path()))]
|
||||
fn process_entry(
|
||||
blob_service: &Box<dyn BlobService>,
|
||||
blob_service: Arc<dyn BlobService>,
|
||||
directory_putter: &mut Box<dyn DirectoryPutter>,
|
||||
entry: &walkdir::DirEntry,
|
||||
maybe_directory: Option<proto::Directory>,
|
||||
|
|
@ -146,8 +147,8 @@ fn process_entry(
|
|||
/// naming scheme.
|
||||
#[instrument(skip(blob_service, directory_service), fields(path=?p))]
|
||||
pub fn ingest_path<P: AsRef<Path> + Debug>(
|
||||
blob_service: &Box<dyn BlobService>,
|
||||
directory_service: &Box<dyn DirectoryService>,
|
||||
blob_service: Arc<dyn BlobService>,
|
||||
directory_service: Arc<dyn DirectoryService>,
|
||||
p: P,
|
||||
) -> Result<proto::node::Node, Error> {
|
||||
// Probe if the path points to a symlink. If it does, we process it manually,
|
||||
|
|
@ -199,7 +200,12 @@ pub fn ingest_path<P: AsRef<Path> + Debug>(
|
|||
}
|
||||
};
|
||||
|
||||
let node = process_entry(blob_service, &mut directory_putter, &entry, maybe_directory)?;
|
||||
let node = process_entry(
|
||||
blob_service.clone(),
|
||||
&mut directory_putter,
|
||||
&entry,
|
||||
maybe_directory,
|
||||
)?;
|
||||
|
||||
if entry.depth() == 0 {
|
||||
return Ok(node);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue