diff options
author | Florian Klink <flokli@flokli.de> | 2023-11-13T10·10+0200 |
---|---|---|
committer | flokli <flokli@flokli.de> | 2023-11-15T06·43+0000 |
commit | f57fd16d6efd1027b3b3b45ca3fdb03573119da6 (patch) | |
tree | b3888666a7b5cdbb6c0a783c439c9f5f31e1f529 /tvix/store/src/pathinfoservice/from_addr.rs | |
parent | 362117fbf56da6cef07bc661ce99e41e7d3cff64 (diff) |
refactor(tvix/store/pathinfosvc): inline GRPCPathInfoSvc::from_url r/7017
Change-Id: Ib53b5525ae13c276e61b7f564673b7c6144ffc0e Reviewed-on: https://cl.tvl.fyi/c/depot/+/10025 Tested-by: BuildkiteCI Reviewed-by: Connor Brewster <cbrewster@hey.com>
Diffstat (limited to 'tvix/store/src/pathinfoservice/from_addr.rs')
-rw-r--r-- | tvix/store/src/pathinfoservice/from_addr.rs | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/tvix/store/src/pathinfoservice/from_addr.rs b/tvix/store/src/pathinfoservice/from_addr.rs index 96a533e290fd..6cace25deaec 100644 --- a/tvix/store/src/pathinfoservice/from_addr.rs +++ b/tvix/store/src/pathinfoservice/from_addr.rs @@ -1,3 +1,5 @@ +use crate::proto::path_info_service_client::PathInfoServiceClient; + use super::{GRPCPathInfoService, MemoryPathInfoService, PathInfoService, SledPathInfoService}; use std::sync::Arc; @@ -42,11 +44,13 @@ pub fn from_addr( directory_service, )?) } else if url.scheme().starts_with("grpc+") { - Arc::new(GRPCPathInfoService::from_url( - &url, - blob_service, - directory_service, - )?) + // schemes starting with grpc+ go to the GRPCPathInfoService. + // That's normally grpc+unix for unix sockets, and grpc+http(s) for the HTTP counterparts. + // - 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 = PathInfoServiceClient::new(tvix_castore::channel::from_url(&url)?); + Arc::new(GRPCPathInfoService::from_client(client)) } else { Err(Error::StorageError(format!( "unknown scheme: {}", @@ -95,4 +99,15 @@ mod tests { fn memory_invalid_path2() { assert!(from_addr("memory:///foo", gen_blob_service(), gen_directory_service()).is_err()) } + + #[tokio::test] + /// This constructs a GRPC PathInfoService. + async fn grpc_valid() { + assert!(from_addr( + "grpc+http://[::1]:12345", + gen_blob_service(), + gen_directory_service() + ) + .is_ok()) + } } |