pub struct QuorumCoordinator { /* private fields */ }Expand description
Tracks per-replica region bindings and pairs them with the primary’s
ack map. PrimaryReplication owns the WAL buffer + ReplicaState
list; this coordinator adds the region dimension and the wait-for-
quorum logic without duplicating the ack table.
Implementations§
Source§impl QuorumCoordinator
impl QuorumCoordinator
pub fn new(primary: Arc<PrimaryReplication>, config: QuorumConfig) -> Self
Sourcepub fn bind_replica_region(&self, replica_id: &str, region: &str)
pub fn bind_replica_region(&self, replica_id: &str, region: &str)
Associate a replica with its region. Called by the primary’s handshake handler when a replica connects — the replica declares its region in the handshake payload.
Sourcepub fn unbind_replica(&self, replica_id: &str)
pub fn unbind_replica(&self, replica_id: &str)
Forget a replica’s region binding on disconnect. Safe to call repeatedly; no-op if the binding doesn’t exist.
Sourcepub fn connected_regions(&self) -> HashSet<String>
pub fn connected_regions(&self) -> HashSet<String>
Which regions currently have at least one connected replica?
Sourcepub fn wait_for_quorum(&self, target_lsn: u64) -> Result<(), QuorumError>
pub fn wait_for_quorum(&self, target_lsn: u64) -> Result<(), QuorumError>
Wait until the configured quorum has acked target_lsn.
Returns Ok(()) on successful quorum, Err(QuorumError) on
timeout or early-exit validation failures. Async mode returns
immediately — the caller already has the primary WAL confirmation.
Sourcepub fn has_quorum(&self, target_lsn: u64) -> bool
pub fn has_quorum(&self, target_lsn: u64) -> bool
Fast-check the quorum predicate without waiting. Returns true
when the current ack map already satisfies the quorum for
target_lsn.
Sourcepub fn safe_replay_lsn(&self) -> Option<u64>
pub fn safe_replay_lsn(&self) -> Option<u64>
Minimum LSN across all connected replicas — the “safe replay”
watermark. Any WAL segment whose records are all <= this can
be pruned from the primary’s spool without losing any replica’s
ability to catch up.
Sourcepub fn config(&self) -> &QuorumConfig
pub fn config(&self) -> &QuorumConfig
Config accessor.
Auto Trait Implementations§
impl !Freeze for QuorumCoordinator
impl !RefUnwindSafe for QuorumCoordinator
impl Send for QuorumCoordinator
impl Sync for QuorumCoordinator
impl Unpin for QuorumCoordinator
impl UnsafeUnpin for QuorumCoordinator
impl UnwindSafe for QuorumCoordinator
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request