From 1cd5cd9e4e6490a981031fb609fec91e6eab5031 Mon Sep 17 00:00:00 2001 From: Esteban Ginez <175813+eginez@users.noreply.github.com> Date: Tue, 9 Jan 2024 09:45:08 -0800 Subject: [PATCH 1/3] add connection timeout setting --- qcs-api-client-grpc/src/channel.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/qcs-api-client-grpc/src/channel.rs b/qcs-api-client-grpc/src/channel.rs index a608b4d..ac821f5 100644 --- a/qcs-api-client-grpc/src/channel.rs +++ b/qcs-api-client-grpc/src/channel.rs @@ -102,9 +102,11 @@ pub fn get_endpoint(uri: Uri) -> Endpoint { } /// Get an [`Endpoint`] for the given [`Uri`] and timeout. -pub fn get_endpoint_with_timeout(uri: Uri, timeout: Option) -> Endpoint { +pub fn get_endpoint_with_timeout(uri: Uri, timeout: Option, connection_timeout: Option) -> Endpoint { if let Some(duration) = timeout { - get_endpoint(uri).timeout(duration) + get_endpoint(uri) + .timeout(duration) + .connect_timeout(connection_timeout.unwrap_or_default()); } else { get_endpoint(uri) } @@ -149,7 +151,7 @@ pub fn get_channel(uri: Uri) -> Result { get_channel_with_endpoint(endpoint) } -/// Get a [`Channel`] to the given [`Uri`], with an optional timeout. If set to [`None`], no timeout is +/// Get a [`Channel`] to the given [`Uri`], with optional timeouts. If set to [`None`], no timeouts are /// used. /// Sets up things like user agent without setting up QCS credentials. /// @@ -164,8 +166,9 @@ pub fn get_channel(uri: Uri) -> Result { pub fn get_channel_with_timeout( uri: Uri, timeout: Option, + connection_timeout: Option, ) -> Result { - let endpoint = get_endpoint_with_timeout(uri, timeout); + let endpoint = get_endpoint_with_timeout(uri, timeout, connection_timeout); get_channel_with_endpoint(endpoint) } From 898d5f20de3ae57059f80cf4bbeb5054c0469191 Mon Sep 17 00:00:00 2001 From: Esteban Ginez <175813+eginez@users.noreply.github.com> Date: Tue, 9 Jan 2024 10:41:14 -0800 Subject: [PATCH 2/3] build failure --- qcs-api-client-grpc/src/channel.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qcs-api-client-grpc/src/channel.rs b/qcs-api-client-grpc/src/channel.rs index ac821f5..f897769 100644 --- a/qcs-api-client-grpc/src/channel.rs +++ b/qcs-api-client-grpc/src/channel.rs @@ -106,7 +106,7 @@ pub fn get_endpoint_with_timeout(uri: Uri, timeout: Option, connection if let Some(duration) = timeout { get_endpoint(uri) .timeout(duration) - .connect_timeout(connection_timeout.unwrap_or_default()); + .connect_timeout(connection_timeout.unwrap_or_default()) } else { get_endpoint(uri) } From edbe7e5735b758c4c190b99eb611c1fa9da532f9 Mon Sep 17 00:00:00 2001 From: Esteban Ginez <175813+eginez@users.noreply.github.com> Date: Tue, 9 Jan 2024 10:41:46 -0800 Subject: [PATCH 3/3] cargo fmt --- qcs-api-client-grpc/src/channel.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qcs-api-client-grpc/src/channel.rs b/qcs-api-client-grpc/src/channel.rs index f897769..01802be 100644 --- a/qcs-api-client-grpc/src/channel.rs +++ b/qcs-api-client-grpc/src/channel.rs @@ -102,7 +102,11 @@ pub fn get_endpoint(uri: Uri) -> Endpoint { } /// Get an [`Endpoint`] for the given [`Uri`] and timeout. -pub fn get_endpoint_with_timeout(uri: Uri, timeout: Option, connection_timeout: Option) -> Endpoint { +pub fn get_endpoint_with_timeout( + uri: Uri, + timeout: Option, + connection_timeout: Option, +) -> Endpoint { if let Some(duration) = timeout { get_endpoint(uri) .timeout(duration)