diff options
Diffstat (limited to 'tvix/castore/src/directoryservice')
-rw-r--r-- | tvix/castore/src/directoryservice/from_addr.rs | 12 | ||||
-rw-r--r-- | tvix/castore/src/directoryservice/grpc.rs | 14 |
2 files changed, 13 insertions, 13 deletions
diff --git a/tvix/castore/src/directoryservice/from_addr.rs b/tvix/castore/src/directoryservice/from_addr.rs index 6082a8b49fb7..8f79fa6158cc 100644 --- a/tvix/castore/src/directoryservice/from_addr.rs +++ b/tvix/castore/src/directoryservice/from_addr.rs @@ -19,7 +19,7 @@ use super::{DirectoryService, GRPCDirectoryService, MemoryDirectoryService, Sled /// Connects to a local tvix-store gRPC service via Unix socket. /// - `grpc+http://host:port`, `grpc+https://host:port` /// Connects to a (remote) tvix-store gRPC service. -pub fn from_addr(uri: &str) -> Result<Arc<dyn DirectoryService>, crate::Error> { +pub async fn from_addr(uri: &str) -> Result<Arc<dyn DirectoryService>, crate::Error> { let url = Url::parse(uri) .map_err(|e| crate::Error::StorageError(format!("unable to parse url: {}", e)))?; @@ -60,7 +60,7 @@ pub fn from_addr(uri: &str) -> Result<Arc<dyn DirectoryService>, crate::Error> { // - In the case of unix sockets, there must be a path, but may not be a host. // - In the case of non-unix sockets, there must be a host, but no path. // Constructing the channel is handled by tvix_castore::channel::from_url. - let client = DirectoryServiceClient::new(crate::channel::from_url(&url)?); + let client = DirectoryServiceClient::new(crate::tonic::channel_from_url(&url).await?); Arc::new(GRPCDirectoryService::from_client(client)) } else { Err(crate::Error::StorageError(format!( @@ -102,12 +102,6 @@ mod tests { #[test_case("memory:///", false; "memory invalid root path")] /// This sets a memory url path to "/foo", which is invalid. #[test_case("memory:///foo", false; "memory invalid root path foo")] - fn test_from_addr(uri_str: &str, is_ok: bool) { - assert_eq!(from_addr(uri_str).is_ok(), is_ok) - } - - // the gRPC tests below don't fail, because we connect lazily. - /// Correct scheme to connect to a unix socket. #[test_case("grpc+unix:///path/to/somewhere", true; "grpc valid unix socket")] /// Correct scheme for unix socket, but setting a host too, which is invalid. @@ -122,6 +116,6 @@ mod tests { #[test_case("grpc+http://localhost/some-path", false; "grpc valid invalid host and path")] #[tokio::test] async fn test_from_addr_tokio(uri_str: &str, is_ok: bool) { - assert_eq!(from_addr(uri_str).is_ok(), is_ok) + assert_eq!(from_addr(uri_str).await.is_ok(), is_ok) } } diff --git a/tvix/castore/src/directoryservice/grpc.rs b/tvix/castore/src/directoryservice/grpc.rs index f0569ac87800..eceaf5ed1f3c 100644 --- a/tvix/castore/src/directoryservice/grpc.rs +++ b/tvix/castore/src/directoryservice/grpc.rs @@ -462,10 +462,16 @@ mod tests { // prepare a client let grpc_client = { - let url = url::Url::parse(&format!("grpc+unix://{}", socket_path.display())) - .expect("must parse"); - let client = - DirectoryServiceClient::new(crate::channel::from_url(&url).expect("must succeed")); + let url = url::Url::parse(&format!( + "grpc+unix://{}?wait-connect=1", + socket_path.display() + )) + .expect("must parse"); + let client = DirectoryServiceClient::new( + crate::tonic::channel_from_url(&url) + .await + .expect("must succeed"), + ); GRPCDirectoryService::from_client(client) }; |