implement quinn max_idle_timeout (for persistant eventeventsource listener)

This commit is contained in:
Jun Kurihara 2023-01-19 18:51:22 +09:00
commit 58f1918b3c
7 changed files with 18 additions and 1 deletions

View file

@ -176,6 +176,14 @@ pub fn parse_opts(globals: &mut Globals) -> std::result::Result<(), anyhow::Erro
if let Some(x) = h3option.max_concurrent_unistream {
globals.h3_max_concurrent_unistream = x.into();
}
if let Some(x) = h3option.max_idle_timeout {
if x == 0u64 {
globals.h3_max_idle_timeout = None;
} else {
globals.h3_max_idle_timeout =
Some(quinn::IdleTimeout::try_from(tokio::time::Duration::from_secs(x)).unwrap())
}
}
}
}

View file

@ -23,6 +23,7 @@ pub struct Http3Option {
pub max_concurrent_connections: Option<u32>,
pub max_concurrent_bidistream: Option<u32>,
pub max_concurrent_unistream: Option<u32>,
pub max_idle_timeout: Option<u64>,
}
#[derive(Deserialize, Debug, Default)]

View file

@ -22,4 +22,5 @@ pub mod H3 {
pub const MAX_CONCURRENT_CONNECTIONS: u32 = 4096;
pub const MAX_CONCURRENT_BIDISTREAM: u32 = 64;
pub const MAX_CONCURRENT_UNISTREAM: u32 = 64;
pub const MAX_IDLE_TIMEOUT: u64 = 10; // secs
}

View file

@ -37,6 +37,8 @@ pub struct Globals {
pub h3_max_concurrent_unistream: quinn::VarInt,
#[cfg(feature = "http3")]
pub h3_max_concurrent_connections: u32,
#[cfg(feature = "http3")]
pub h3_max_idle_timeout: Option<quinn::IdleTimeout>,
}
#[derive(Debug, Clone, Default)]

View file

@ -89,6 +89,8 @@ fn main() {
h3_max_concurrent_bidistream: H3::MAX_CONCURRENT_BIDISTREAM.into(),
#[cfg(feature = "http3")]
h3_max_concurrent_unistream: H3::MAX_CONCURRENT_UNISTREAM.into(),
#[cfg(feature = "http3")]
h3_max_idle_timeout: Some(quinn::IdleTimeout::try_from(Duration::from_secs(H3::MAX_IDLE_TIMEOUT)).unwrap()),
};
if let Err(e) = parse_opts(&mut globals) {

View file

@ -130,7 +130,8 @@ where
let mut transport_config_quic = TransportConfig::default();
transport_config_quic
.max_concurrent_bidi_streams(self.globals.h3_max_concurrent_bidistream)
.max_concurrent_uni_streams(self.globals.h3_max_concurrent_unistream);
.max_concurrent_uni_streams(self.globals.h3_max_concurrent_unistream)
.max_idle_timeout(self.globals.h3_max_idle_timeout);
let mut server_config_h3 = QuicServerConfig::with_crypto(Arc::new(rustls_server_config));
server_config_h3.transport = Arc::new(transport_config_quic);