caio.co/de/foca

New (unstable) notification on failed probe

Id
4cf331c451848b1545f70a1937f6f7bf76ae5c3b
Author
Caio
Commit time
2024-10-04T11:05:25+02:00

Modified src/lib.rs

@@ -1149,6 +1149,12
}

if let Some(failed) = self.probe.take_failed() {
+ #[cfg(feature = "unstable-notifications")]
+ runtime.notify(Notification::ProbeFailed(
+ self.probe.probe_number(),
+ failed.id(),
+ ));
+
// Applying here can fail if:
//
// 1. The member increased its incarnation since the probe started

Modified src/runtime.rs

@@ -7,7 +7,7
use bytes::{Bytes, BytesMut};

#[cfg(feature = "unstable-notifications")]
-use crate::Header;
+use crate::{Header, ProbeNumber};
use crate::{Identity, Incarnation};

/// A Runtime is Foca's gateway to the real world: here is where
@@ -138,6 +138,13
///
/// See [`Header`]
DataSent(&'a Header<T>),
+
+ #[cfg(feature = "unstable-notifications")]
+ /// Foca has probed a member and didn't receive a timely reply
+ /// from it nor from any other member asked to indirectly ping it
+ ///
+ /// See [`crate::Message`]
+ ProbeFailed(ProbeNumber, &'a T),
}

impl<'a, T> Notification<'a, T>
@@ -160,6 +167,8
Notification::DataReceived(h) => OwnedNotification::DataReceived(h.clone()),
#[cfg(feature = "unstable-notifications")]
Notification::DataSent(h) => OwnedNotification::DataSent(h.clone()),
+ #[cfg(feature = "unstable-notifications")]
+ Notification::ProbeFailed(n, m) => OwnedNotification::ProbeFailed(n, m.clone()),
}
}
}
@@ -190,6 +199,10
#[cfg(feature = "unstable-notifications")]
/// See [`Notification::DataSent`]
DataSent(Header<T>),
+
+ #[cfg(feature = "unstable-notifications")]
+ /// See [`Notification::ProbeFailed`]
+ ProbeFailed(ProbeNumber, T),
}

/// Timer is an event that's scheduled by a [`Runtime`]. You won't need