protocols/ping: Properly deprecate types with Ping prefix (#2937)

Co-authored-by: Elena Frank <elena.frank@protonmail.com>
Co-authored-by:  João Oliveira <hello@jxs.pt>
This commit is contained in:
Thomas Eizinger
2022-10-01 00:19:34 +10:00
committed by GitHub
parent cce296e55e
commit 1da75b2b25
17 changed files with 162 additions and 159 deletions

View File

@ -126,8 +126,8 @@ impl Recorder<libp2p_kad::KademliaEvent> for Metrics {
}
#[cfg(feature = "ping")]
impl Recorder<libp2p_ping::PingEvent> for Metrics {
fn record(&self, event: &libp2p_ping::PingEvent) {
impl Recorder<libp2p_ping::Event> for Metrics {
fn record(&self, event: &libp2p_ping::Event) {
self.ping.record(event)
}
}

View File

@ -29,16 +29,16 @@ struct FailureLabels {
reason: Failure,
}
impl From<&libp2p_ping::PingFailure> for FailureLabels {
fn from(failure: &libp2p_ping::PingFailure) -> Self {
impl From<&libp2p_ping::Failure> for FailureLabels {
fn from(failure: &libp2p_ping::Failure) -> Self {
match failure {
libp2p_ping::PingFailure::Timeout => FailureLabels {
libp2p_ping::Failure::Timeout => FailureLabels {
reason: Failure::Timeout,
},
libp2p_ping::PingFailure::Unsupported => FailureLabels {
libp2p_ping::Failure::Unsupported => FailureLabels {
reason: Failure::Unsupported,
},
libp2p_ping::PingFailure::Other { .. } => FailureLabels {
libp2p_ping::Failure::Other { .. } => FailureLabels {
reason: Failure::Other,
},
}
@ -92,13 +92,13 @@ impl Metrics {
}
}
impl super::Recorder<libp2p_ping::PingEvent> for Metrics {
fn record(&self, event: &libp2p_ping::PingEvent) {
impl super::Recorder<libp2p_ping::Event> for Metrics {
fn record(&self, event: &libp2p_ping::Event) {
match &event.result {
Ok(libp2p_ping::PingSuccess::Pong) => {
Ok(libp2p_ping::Success::Pong) => {
self.pong_received.inc();
}
Ok(libp2p_ping::PingSuccess::Ping { rtt }) => {
Ok(libp2p_ping::Success::Ping { rtt }) => {
self.rtt.observe(rtt.as_secs_f64());
}
Err(failure) => {