pub struct ChangeLog { /* private fields */ }Expand description
An in-memory change log with bounded retention.
Older events are evicted when the log exceeds capacity. The sequence
counter still increments monotonically; clients pulling with an old
cursor will see only what remains in memory (or should issue a full
re-sync if their cursor falls off the back).
Implementations§
Source§impl ChangeLog
impl ChangeLog
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create a new change log with a specific capacity.
Sourcepub fn has_seen_op_id(&self, op_id: &str) -> bool
pub fn has_seen_op_id(&self, op_id: &str) -> bool
Returns true if this op_id was already applied. Used by the push
handler to short-circuit replays. Callers that observe true should
NOT re-apply the change and should return success to the client.
Sourcepub fn remember_op_id(&self, op_id: &str)
pub fn remember_op_id(&self, op_id: &str)
Mark an op_id as processed. Safe to call multiple times. Evicts the
oldest entry when the cache exceeds op_id_capacity.
Sourcepub fn append(
&self,
entity: &str,
row_id: &str,
kind: ChangeKind,
data: Option<Value>,
) -> u64
pub fn append( &self, entity: &str, row_id: &str, kind: ChangeKind, data: Option<Value>, ) -> u64
Append a change event. Returns the assigned sequence number.
Sourcepub fn pull(
&self,
cursor: &SyncCursor,
limit: usize,
) -> Result<PullResponse, PullError>
pub fn pull( &self, cursor: &SyncCursor, limit: usize, ) -> Result<PullResponse, PullError>
Pull changes since a cursor, up to a limit.
Returns Err(PullError::ResyncRequired) when the caller’s cursor has
fallen off the back of the retention window — i.e. the cursor’s
last_seq is lower than the oldest seq we still remember. Previously
this case was silent: pull would return the surviving tail and
advance the cursor, so the client converged to a state that skipped
the evicted events entirely. That’s a permanent correctness bug;
clients should instead do a full re-sync from entity list state.