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
|
|
@ -11,14 +11,14 @@ use std::{
|
|||
pub struct MemoryPathInfoService {
|
||||
db: Arc<RwLock<HashMap<[u8; 20], proto::PathInfo>>>,
|
||||
|
||||
blob_service: Box<dyn BlobService>,
|
||||
directory_service: Box<dyn DirectoryService>,
|
||||
blob_service: Arc<dyn BlobService>,
|
||||
directory_service: Arc<dyn DirectoryService>,
|
||||
}
|
||||
|
||||
impl MemoryPathInfoService {
|
||||
pub fn new(
|
||||
blob_service: Box<dyn BlobService>,
|
||||
directory_service: Box<dyn DirectoryService>,
|
||||
blob_service: Arc<dyn BlobService>,
|
||||
directory_service: Arc<dyn DirectoryService>,
|
||||
) -> Self {
|
||||
Self {
|
||||
db: Default::default(),
|
||||
|
|
@ -58,7 +58,11 @@ impl PathInfoService for MemoryPathInfoService {
|
|||
}
|
||||
|
||||
fn calculate_nar(&self, root_node: &proto::node::Node) -> Result<(u64, [u8; 32]), Error> {
|
||||
calculate_size_and_sha256(root_node, &self.blob_service, &self.directory_service)
|
||||
.map_err(|e| Error::StorageError(e.to_string()))
|
||||
calculate_size_and_sha256(
|
||||
root_node,
|
||||
self.blob_service.clone(),
|
||||
self.directory_service.clone(),
|
||||
)
|
||||
.map_err(|e| Error::StorageError(e.to_string()))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue