feat(swarm): deprecated keep_alive_timeout from OneShotHandlerConfig

Related: #3844.
Related: #4677

Pull-Request: #4680.
This commit is contained in:
Leonz
2023-10-18 04:41:04 +08:00
committed by GitHub
parent 411824ad50
commit 203e11c1c8
2 changed files with 6 additions and 0 deletions

View File

@ -10,6 +10,8 @@
Individual protocols should not keep connections alive for longer than necessary. Individual protocols should not keep connections alive for longer than necessary.
Users should use `swarm::Config::idle_connection_timeout` instead. Users should use `swarm::Config::idle_connection_timeout` instead.
See [PR 4656](https://github.com/libp2p/rust-libp2p/pull/4656). See [PR 4656](https://github.com/libp2p/rust-libp2p/pull/4656).
- Deprecate `keep_alive_timeout` in `OneShotHandlerConfig`.
See [PR 4680](https://github.com/libp2p/rust-libp2p/pull/4680).
[PR 4120]: https://github.com/libp2p/rust-libp2p/pull/4120 [PR 4120]: https://github.com/libp2p/rust-libp2p/pull/4120

View File

@ -233,6 +233,9 @@ where
#[derive(Debug)] #[derive(Debug)]
pub struct OneShotHandlerConfig { pub struct OneShotHandlerConfig {
/// Keep-alive timeout for idle connections. /// Keep-alive timeout for idle connections.
#[deprecated(
note = "Set a global idle connection timeout via `SwarmBuilder::idle_connection_timeout` instead."
)]
pub keep_alive_timeout: Duration, pub keep_alive_timeout: Duration,
/// Timeout for outbound substream upgrades. /// Timeout for outbound substream upgrades.
pub outbound_substream_timeout: Duration, pub outbound_substream_timeout: Duration,
@ -241,6 +244,7 @@ pub struct OneShotHandlerConfig {
} }
impl Default for OneShotHandlerConfig { impl Default for OneShotHandlerConfig {
#[allow(deprecated)]
fn default() -> Self { fn default() -> Self {
OneShotHandlerConfig { OneShotHandlerConfig {
keep_alive_timeout: Duration::from_secs(10), keep_alive_timeout: Duration::from_secs(10),