diff --git a/services/commtest/src/tunnelbroker/tunnelbroker_utils.rs b/services/commtest/src/tunnelbroker/tunnelbroker_utils.rs --- a/services/commtest/src/tunnelbroker/tunnelbroker_utils.rs +++ b/services/commtest/src/tunnelbroker/tunnelbroker_utils.rs @@ -1,4 +1,17 @@ +use std::env; +use tonic::transport::Channel; +use tonic::transport::Error; pub mod proto { tonic::include_proto!("tunnelbroker"); } pub use proto::tunnelbroker_service_client::TunnelbrokerServiceClient; + +pub async fn tonic_client_builder( +) -> Result, Error> { + let port = env::var("COMM_SERVICES_TUNNELBROKER_PORT").expect( + "`COMM_SERVICES_TUNNELBROKER_PORT` environment variable expected but not received", + ); + let host = env::var("COMM_SERVICES_TUNNELBROKER_HOST") + .unwrap_or(String::from("localhost")); + TunnelbrokerServiceClient::connect(format!("http://{}:{}", host, port)).await +}