pub struct Heartbeat { /* private fields */ }Expand description
Heartbeat mechanism for long-running nodes
Nodes can send heartbeats to indicate they are still active,
preventing idle timeout detection. The heartbeat carries an
unbounded channel sender that signals the engine’s idle-timeout
watchdog each time ping() is called.
Create paired heartbeat and watcher with Heartbeat::new_pair:
ⓘ
use juncture_core::Heartbeat;
use std::time::Duration;
let (heartbeat, mut watcher) = Heartbeat::new_pair();
heartbeat.ping().unwrap();
assert!(watcher.is_alive(Duration::from_secs(10)));Implementations§
Source§impl Heartbeat
impl Heartbeat
Sourcepub const fn new(tx: UnboundedSender<()>) -> Self
pub const fn new(tx: UnboundedSender<()>) -> Self
Create a new heartbeat from an unbounded sender
Sourcepub fn new_pair() -> (Self, HeartbeatWatcher)
pub fn new_pair() -> (Self, HeartbeatWatcher)
Create a paired heartbeat sender and watcher
Returns a (Heartbeat, HeartbeatWatcher) pair connected
by an unbounded channel. The watcher can detect staleness
by checking whether heartbeats arrived within the idle timeout.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Heartbeat
impl RefUnwindSafe for Heartbeat
impl Send for Heartbeat
impl Sync for Heartbeat
impl Unpin for Heartbeat
impl UnsafeUnpin for Heartbeat
impl UnwindSafe for Heartbeat
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more