diff options
author | Florian Klink <flokli@flokli.de> | 2024-11-09T13·16+0000 |
---|---|---|
committer | flokli <flokli@flokli.de> | 2024-11-11T18·46+0000 |
commit | d505f03e005b87d315694a22a75c11205266ba7d (patch) | |
tree | 67efb1d5d1756e7dce67f95b877a92bd5004bc7e /tvix/castore/src | |
parent | 8df919dcf04b5c2502f3a63b4d013669da5e70c1 (diff) |
refactor(tvix/store/composition): rename 'default' to 'root' r/8899
This becomes the root of the composition. `default` implies we can directly access anything else, which we cannot. `root` makes this more understandable, and it's all internal only anyways. Change-Id: I297511bc05a7c32c59510b9d192b40d1bd937b5f Reviewed-on: https://cl.tvl.fyi/c/depot/+/12746 Reviewed-by: yuka <yuka@yuka.dev> Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/castore/src')
-rw-r--r-- | tvix/castore/src/blobservice/grpc.rs | 2 | ||||
-rw-r--r-- | tvix/castore/src/blobservice/tests/utils.rs | 2 | ||||
-rw-r--r-- | tvix/castore/src/composition.rs | 22 | ||||
-rw-r--r-- | tvix/castore/src/directoryservice/object_store.rs | 2 | ||||
-rw-r--r-- | tvix/castore/src/directoryservice/redb.rs | 2 | ||||
-rw-r--r-- | tvix/castore/src/directoryservice/tests/utils.rs | 2 |
6 files changed, 16 insertions, 16 deletions
diff --git a/tvix/castore/src/blobservice/grpc.rs b/tvix/castore/src/blobservice/grpc.rs index 3453657d07ab..9f3efbe6763d 100644 --- a/tvix/castore/src/blobservice/grpc.rs +++ b/tvix/castore/src/blobservice/grpc.rs @@ -385,7 +385,7 @@ mod tests { .await .expect("must succeed"), ); - GRPCBlobService::from_client("default".into(), client) + GRPCBlobService::from_client("root".into(), client) }; let has = grpc_client diff --git a/tvix/castore/src/blobservice/tests/utils.rs b/tvix/castore/src/blobservice/tests/utils.rs index 7032d633dad0..c7e41d965504 100644 --- a/tvix/castore/src/blobservice/tests/utils.rs +++ b/tvix/castore/src/blobservice/tests/utils.rs @@ -30,7 +30,7 @@ pub async fn make_grpc_blob_service_client() -> Box<dyn BlobService> { let mut maybe_right = Some(right); Box::new(GRPCBlobService::from_client( - "default".into(), + "root".into(), BlobServiceClient::new( Endpoint::try_from("http://[::]:50051") .unwrap() diff --git a/tvix/castore/src/composition.rs b/tvix/castore/src/composition.rs index b251187e1c34..c6fa1ce64ac4 100644 --- a/tvix/castore/src/composition.rs +++ b/tvix/castore/src/composition.rs @@ -62,7 +62,7 @@ //! "blobstore2": { //! "type": "memory" //! }, -//! "default": { +//! "root": { //! "type": "combined", //! "local": "blobstore1", //! "remote": "blobstore2" @@ -72,7 +72,7 @@ //! let blob_services_configs = with_registry(®, || serde_json::from_value(blob_services_configs_json))?; //! let mut blob_service_composition = Composition::new(®); //! blob_service_composition.extend_with_configs::<dyn BlobService>(blob_services_configs); -//! let blob_service: Arc<dyn BlobService> = blob_service_composition.build("default").await?; +//! let blob_service: Arc<dyn BlobService> = blob_service_composition.build("root").await?; //! # Ok(()) //! # }) //! # } @@ -281,7 +281,7 @@ pub fn add_default_services(reg: &mut Registry) { pub struct CompositionContext<'a> { // The stack used to detect recursive instantiations and prevent deadlocks // The TypeId of the trait object is included to distinguish e.g. the - // BlobService "default" and the DirectoryService "default". + // BlobService "root" and the DirectoryService "root". stack: Vec<(TypeId, String)>, registry: &'static Registry, composition: Option<&'a Composition>, @@ -529,7 +529,7 @@ mod test { #[tokio::test] async fn concurrent() { let blob_services_configs_json = serde_json::json!({ - "default": { + "root": { "type": "memory", } }); @@ -539,8 +539,8 @@ mod test { let mut blob_service_composition = Composition::new(®); blob_service_composition.extend_with_configs::<dyn BlobService>(blob_services_configs); let (blob_service1, blob_service2) = tokio::join!( - blob_service_composition.build::<dyn BlobService>("default"), - blob_service_composition.build::<dyn BlobService>("default") + blob_service_composition.build::<dyn BlobService>("root"), + blob_service_composition.build::<dyn BlobService>("root") ); assert!(Arc::ptr_eq( &blob_service1.unwrap(), @@ -552,15 +552,15 @@ mod test { #[tokio::test] async fn reject_recursion() { let blob_services_configs_json = serde_json::json!({ - "default": { + "root": { "type": "combined", "local": "other", "remote": "other" }, "other": { "type": "combined", - "local": "default", - "remote": "default" + "local": "root", + "remote": "root" } }); @@ -569,11 +569,11 @@ mod test { let mut blob_service_composition = Composition::new(®); blob_service_composition.extend_with_configs::<dyn BlobService>(blob_services_configs); match blob_service_composition - .build::<dyn BlobService>("default") + .build::<dyn BlobService>("root") .await { Err(CompositionError::Recursion(stack)) => { - assert_eq!(stack, vec!["default".to_string(), "other".to_string()]) + assert_eq!(stack, vec!["root".to_string(), "other".to_string()]) } other => panic!("should have returned an error, returned: {:?}", other.err()), } diff --git a/tvix/castore/src/directoryservice/object_store.rs b/tvix/castore/src/directoryservice/object_store.rs index 77578ec92f02..1916e59eacaa 100644 --- a/tvix/castore/src/directoryservice/object_store.rs +++ b/tvix/castore/src/directoryservice/object_store.rs @@ -64,7 +64,7 @@ impl ObjectStoreDirectoryService { let (object_store, path) = object_store::parse_url_opts(url, options)?; Ok(Self { - instance_name: "default".into(), + instance_name: "root".into(), object_store: Arc::new(object_store), base_path: path, }) diff --git a/tvix/castore/src/directoryservice/redb.rs b/tvix/castore/src/directoryservice/redb.rs index ba1fb682d5da..246d64173f10 100644 --- a/tvix/castore/src/directoryservice/redb.rs +++ b/tvix/castore/src/directoryservice/redb.rs @@ -56,7 +56,7 @@ impl RedbDirectoryService { create_schema(&db)?; Ok(Self { - instance_name: "default".into(), + instance_name: "root".into(), db: Arc::new(db), }) } diff --git a/tvix/castore/src/directoryservice/tests/utils.rs b/tvix/castore/src/directoryservice/tests/utils.rs index 1c5d68de0108..f2aefa32b3cc 100644 --- a/tvix/castore/src/directoryservice/tests/utils.rs +++ b/tvix/castore/src/directoryservice/tests/utils.rs @@ -33,7 +33,7 @@ pub async fn make_grpc_directory_service_client() -> Box<dyn DirectoryService> { // Create a client, connecting to the right side. The URI is unused. let mut maybe_right = Some(right); Box::new(GRPCDirectoryService::from_client( - "default".into(), + "root".into(), DirectoryServiceClient::new( Endpoint::try_from("http://[::]:50051") .unwrap() |