refactor(tvix/glue): add BuildService to TvixStoreIO

TvixStoreIO triggers builds whenever IO into a not-yet-built store path
is requested, if it knows how to build that path.

Change-Id: If30e9db6be2f2a30cbc9d0576f357f3ecfa0d35a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10645
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Tested-by: BuildkiteCI
This commit is contained in:
Florian Klink 2024-01-16 13:14:07 +02:00 committed by flokli
parent 12ae96cff2
commit 501827db59
8 changed files with 25 additions and 6 deletions

View file

@ -9,6 +9,7 @@ use std::{
};
use tokio::io::AsyncReadExt;
use tracing::{error, instrument, warn};
use tvix_build::buildservice::BuildService;
use tvix_eval::{EvalIO, FileType, StdIO};
use tvix_castore::{
@ -41,6 +42,8 @@ pub struct TvixStoreIO {
directory_service: Arc<dyn DirectoryService>,
path_info_service: Arc<dyn PathInfoService>,
std_io: StdIO,
#[allow(dead_code)]
build_service: Arc<dyn BuildService>,
tokio_handle: tokio::runtime::Handle,
pub(crate) known_paths: RefCell<KnownPaths>,
}
@ -50,6 +53,7 @@ impl TvixStoreIO {
blob_service: Arc<dyn BlobService>,
directory_service: Arc<dyn DirectoryService>,
path_info_service: Arc<dyn PathInfoService>,
build_service: Arc<dyn BuildService>,
tokio_handle: tokio::runtime::Handle,
) -> Self {
Self {
@ -57,6 +61,7 @@ impl TvixStoreIO {
directory_service,
path_info_service,
std_io: StdIO {},
build_service,
tokio_handle,
known_paths: Default::default(),
}
@ -292,6 +297,7 @@ mod tests {
use std::{path::Path, rc::Rc, sync::Arc};
use tempfile::TempDir;
use tvix_build::buildservice::DummyBuildService;
use tvix_castore::{
blobservice::{BlobService, MemoryBlobService},
directoryservice::{DirectoryService, MemoryDirectoryService},
@ -314,12 +320,14 @@ mod tests {
blob_service.clone(),
directory_service.clone(),
));
let runtime = tokio::runtime::Runtime::new().unwrap();
let io = Rc::new(TvixStoreIO::new(
blob_service.clone(),
directory_service.clone(),
path_info_service,
Arc::<DummyBuildService>::default(),
runtime.handle().clone(),
));
let mut eval = tvix_eval::Evaluation::new(io.clone() as Rc<dyn EvalIO>, true);