pub struct Config { /* private fields */ }
Expand description
The configuration for outbound pings.
Implementations§
source§impl Config
impl Config
sourcepub fn new() -> Config
pub fn new() -> Config
Creates a new Config
with the following default settings:
Config::with_interval
15sConfig::with_timeout
20sConfig::with_max_failures
1Config::with_keep_alive
false
These settings have the following effect:
- A ping is sent every 15 seconds on a healthy connection.
- Every ping sent must yield a response within 20 seconds in order to be successful.
- A single ping failure is sufficient for the connection to be subject to being closed.
- The connection may be closed at any time as far as the ping protocol is concerned, i.e. the ping protocol itself does not keep the connection alive.
sourcepub fn with_timeout(self, d: Duration) -> Config
pub fn with_timeout(self, d: Duration) -> Config
Sets the ping timeout.
sourcepub fn with_interval(self, d: Duration) -> Config
pub fn with_interval(self, d: Duration) -> Config
Sets the ping interval.
sourcepub fn with_max_failures(self, n: NonZeroU32) -> Config
pub fn with_max_failures(self, n: NonZeroU32) -> Config
Sets the maximum number of consecutive ping failures upon which the remote peer is considered unreachable and the connection closed.
sourcepub fn with_keep_alive(self, b: bool) -> Config
👎Deprecated since 0.40.0: Use libp2p::swarm::behaviour::KeepAlive
if you need to keep connections alive unconditionally.
pub fn with_keep_alive(self, b: bool) -> Config
libp2p::swarm::behaviour::KeepAlive
if you need to keep connections alive unconditionally.Sets whether the ping protocol itself should keep the connection alive, apart from the maximum allowed failures.
By default, the ping protocol itself allows the connection to be closed at any time, i.e. in the absence of ping failures the connection lifetime is determined by other protocol handlers.
If the maximum number of allowed ping failures is reached, the
connection is always terminated as a result of ConnectionHandler::poll
returning an error, regardless of the keep-alive setting.