Struct libp2p_ping::Config
source · pub struct Config { /* private fields */ }
Expand description
The configuration for outbound pings.
Implementations§
source§impl Config
impl Config
sourcepub fn new() -> Self
pub fn new() -> Self
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) -> Self
pub fn with_timeout(self, d: Duration) -> Self
Sets the ping timeout.
sourcepub fn with_interval(self, d: Duration) -> Self
pub fn with_interval(self, d: Duration) -> Self
Sets the ping interval.
sourcepub fn with_max_failures(self, n: NonZeroU32) -> Self
pub fn with_max_failures(self, n: NonZeroU32) -> Self
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) -> Self
👎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) -> Self
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.