Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions qcs-api-client-grpc/src/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,15 @@ 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<Duration>) -> Endpoint {
pub fn get_endpoint_with_timeout(
uri: Uri,
timeout: Option<Duration>,
connection_timeout: Option<Duration>,
) -> 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)
}
Expand Down Expand Up @@ -149,7 +155,7 @@ pub fn get_channel(uri: Uri) -> Result<Channel, ChannelError> {
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.
///
Expand All @@ -164,8 +170,9 @@ pub fn get_channel(uri: Uri) -> Result<Channel, ChannelError> {
pub fn get_channel_with_timeout(
uri: Uri,
timeout: Option<Duration>,
connection_timeout: Option<Duration>,
) -> Result<Channel, ChannelError> {
let endpoint = get_endpoint_with_timeout(uri, timeout);
let endpoint = get_endpoint_with_timeout(uri, timeout, connection_timeout);
get_channel_with_endpoint(endpoint)
}

Expand Down