Skip to content

Commit

Permalink
Merge pull request #224 from superfly/client-keep-alive
Browse files Browse the repository at this point in the history
corro-client: enable HTTP2 keep-alives
  • Loading branch information
pborzenkov authored Jun 27, 2024
2 parents b07c13d + 99d5edb commit 9aa1487
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions crates/corro-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::{
ops::Deref,
path::Path,
sync::Arc,
time::{self, Instant},
time::{self, Duration, Instant},
};
use sub::{QueryStream, SubscriptionStream};
use tokio::sync::{RwLock, RwLockReadGuard};
Expand All @@ -21,6 +21,8 @@ use trust_dns_resolver::{
};
use uuid::Uuid;

const HTTP2_KEEP_ALIVE_INTERVAL: Duration = Duration::from_secs(10);

#[derive(Clone)]
pub struct CorrosionApiClient {
api_addr: SocketAddr,
Expand All @@ -31,7 +33,11 @@ impl CorrosionApiClient {
pub fn new(api_addr: SocketAddr) -> Self {
Self {
api_addr,
api_client: hyper::Client::builder().http2_only(true).build_http(),
api_client: hyper::Client::builder()
.http2_only(true)
.http2_keep_alive_interval(Some(HTTP2_KEEP_ALIVE_INTERVAL))
.http2_keep_alive_timeout(HTTP2_KEEP_ALIVE_INTERVAL / 2)
.build_http(),
}
}

Expand Down

0 comments on commit 9aa1487

Please sign in to comment.