HeartbeatMonitor class
Watches node liveness and reports nodes that have stopped heartbeating.
On each tick (driven by a periodic timer in production, or called directly in tests), any node whose last-seen time is older than timeout is passed to onTimeout for teardown. All timing is Clock-driven so tests stay deterministic.
Constructors
- HeartbeatMonitor({required NodeRegistry registry, required void onTimeout(RegisteredNode node), Clock clock = const SystemClock(), Duration timeout = const Duration(seconds: 30)})
- Creates a heartbeat monitor.
Properties
- clock → Clock
-
The clock providing "now".
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- onTimeout → void Function(RegisteredNode node)
-
Invoked for each node that has timed out.
final
- registry → NodeRegistry
-
The registry to scan.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- timeout → Duration
-
How long a node may go silent before being declared offline.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
start(
{Duration? interval}) → void -
Starts periodic checking every
interval(default: a third of timeout). -
stop(
) → void - Stops periodic checking.
-
tick(
) → void - Scans the registry once, reporting any timed-out nodes.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited