pub struct LogicalChangeApplier { /* private fields */ }Expand description
Shared logical change applier so replica replay and PITR converge on the same semantics. Stateful (PLAN.md Phase 11.5): tracks the last applied LSN + payload hash so duplicates / older LSNs / gaps / divergences are detected explicitly.
Implementations§
Source§impl LogicalChangeApplier
impl LogicalChangeApplier
Sourcepub fn new(starting_lsn: u64) -> LogicalChangeApplier
pub fn new(starting_lsn: u64) -> LogicalChangeApplier
Build a fresh applier. starting_lsn is the LSN already
covered by the snapshot (or 0 for an empty replica). The
next acceptable record is any positive LSN; from there the
chain advances by 1.
pub fn last_applied_lsn(&self) -> u64
Sourcepub fn apply(
&self,
db: &RedDB,
record: &ChangeRecord,
mode: ApplyMode,
) -> Result<ApplyOutcome, LogicalApplyError>
pub fn apply( &self, db: &RedDB, record: &ChangeRecord, mode: ApplyMode, ) -> Result<ApplyOutcome, LogicalApplyError>
Apply one logical change record. The state machine:
- first record after
starting_lsn == 0→ apply, anchor. lsn == last + 1→ apply, advance.lsn == last&& payload hash equal → idempotent skip.lsn == last&& payload hash differs →Divergence(fail closed).lsn < last→ older replay, skip with debug log.lsn > last + 1→Gap(fail closed; caller marks unhealthy).
Sourcepub fn apply_record(
db: &RedDB,
record: &ChangeRecord,
_mode: ApplyMode,
) -> Result<(), RedDBError>
pub fn apply_record( db: &RedDB, record: &ChangeRecord, _mode: ApplyMode, ) -> Result<(), RedDBError>
Stateless apply — applies the record without monotonicity
checks. Kept for callers that don’t yet thread the stateful
applier through. New code should prefer
LogicalChangeApplier::new() + apply().
Auto Trait Implementations§
impl !Freeze for LogicalChangeApplier
impl RefUnwindSafe for LogicalChangeApplier
impl Send for LogicalChangeApplier
impl Sync for LogicalChangeApplier
impl Unpin for LogicalChangeApplier
impl UnsafeUnpin for LogicalChangeApplier
impl UnwindSafe for LogicalChangeApplier
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
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>
Converts
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>
Converts
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>
Wrap the input message
T in a tonic::Request