nodedb_cluster/applied_watcher/mod.rs
1// SPDX-License-Identifier: BUSL-1.1
2
3//! Per-Raft-group applied-index watchers.
4//!
5//! A single primitive — [`AppliedIndexWatcher`] — tracks the highest
6//! log index applied on this node for one Raft group. The
7//! [`GroupAppliedWatchers`] registry indexes one watcher per group so
8//! callers (proposers, consistent reads, lease renewals, recovery
9//! checks) can wait on the apply watermark of *their* group rather
10//! than only the metadata group.
11//!
12//! Bump points (single source of truth for "applied on this node"):
13//!
14//! 1. [`crate::raft_loop::tick`] after the per-group apply phase
15//! — covers regular committed-entry application for every locally
16//! mounted group, including the metadata group.
17//! 2. [`crate::raft_loop::handle_rpc`] after `handle_install_snapshot`
18//! — covers the snapshot-install path where `last_applied` jumps
19//! to `last_included_index` without going through the apply loop.
20//!
21//! Both bump points read the canonical applied index from the Raft
22//! node itself rather than mirroring it from a side channel, so the
23//! watcher cannot drift from Raft's own state.
24
25pub mod registry;
26pub mod watcher;
27
28pub use registry::GroupAppliedWatchers;
29pub use watcher::{AppliedIndexWatcher, WaitOutcome};