From f6d1a56c8c2446b97e4147980a842d0a9de04e75 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Sun, 31 Dec 2023 16:33:26 +0200 Subject: refactor(tvix/store): move construct_services helper here This takes three URLs, and constructs Arc'ed {Blob,Directory,PathInfo}Service, allowing to remove some of the boilerplate. Change-Id: I40e7c2b551442ef2acdc543dfc87ab97e7c742bb Reviewed-on: https://cl.tvl.fyi/c/depot/+/10484 Autosubmit: flokli Tested-by: BuildkiteCI Reviewed-by: raitobezarius --- tvix/store/src/utils.rs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tvix/store/src/utils.rs (limited to 'tvix/store/src/utils.rs') diff --git a/tvix/store/src/utils.rs b/tvix/store/src/utils.rs new file mode 100644 index 0000000000..041a9e683d --- /dev/null +++ b/tvix/store/src/utils.rs @@ -0,0 +1,35 @@ +use std::sync::Arc; + +use tvix_castore::{ + blobservice::{self, BlobService}, + directoryservice::{self, DirectoryService}, +}; + +use crate::pathinfoservice::{self, PathInfoService}; + +/// Construct the three store handles from their addrs. +pub async fn construct_services( + blob_service_addr: impl AsRef, + directory_service_addr: impl AsRef, + path_info_service_addr: impl AsRef, +) -> std::io::Result<( + Arc, + Arc, + Box, +)> { + let blob_service: Arc = blobservice::from_addr(blob_service_addr.as_ref()) + .await? + .into(); + let directory_service: Arc = + directoryservice::from_addr(directory_service_addr.as_ref()) + .await? + .into(); + let path_info_service = pathinfoservice::from_addr( + path_info_service_addr.as_ref(), + blob_service.clone(), + directory_service.clone(), + ) + .await?; + + Ok((blob_service, directory_service, path_info_service)) +} -- cgit 1.4.1