Skip to content
Open
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
10 changes: 8 additions & 2 deletions qcs-api-client-grpc/src/tonic/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,10 @@ pub fn parse_uri(s: &str) -> Result<Uri, Error<TokenError>> {
s.parse().map_err(Error::from)
}

/// Get an [`Endpoint`] for the given [`Uri`]
/// Get an [`Endpoint`] for the given [`Uri`] with default settings.
/// This endpoint will default to using a 5 minute timeout, and will
/// keep the connection alive while idle, with a 120 second keep-alive
/// interval.
#[allow(clippy::missing_panics_doc)]
pub fn get_endpoint(uri: Uri) -> Endpoint {
Channel::builder(uri)
Expand All @@ -351,9 +354,12 @@ pub fn get_endpoint(uri: Uri) -> Endpoint {
.expect("user agent string should be valid")
.tls_config(ClientTlsConfig::new().with_enabled_roots())
.expect("tls setup should succeed")
.keep_alive_while_idle(true)
.http2_keep_alive_interval(Duration::from_secs(120))
.timeout(Duration::from_secs(300))
Comment on lines +357 to +359
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this to hopefully keep the endpoint connection live when idling. Als upped the keep_alive_interval to 2 minutes.

}

/// Get an [`Endpoint`] for the given [`Uri`] and timeout.
/// Get an [`Endpoint`] for the given [`Uri`] and custom timeout duration.
pub fn get_endpoint_with_timeout(uri: Uri, timeout: Option<Duration>) -> Endpoint {
if let Some(duration) = timeout {
get_endpoint(uri).timeout(duration)
Expand Down