Skip to main content

Module source

Module source 

Source
Expand description

Primary-side replication source — bounded backlog of recent mutations, indexed by monotonic offset.

Behaviour at a glance:

  • ReplicationSource::push_mutation is called on every applied write. It assigns the next monotonic offset, encodes the frame with crate::wire::encode_frame, and appends to the backlog.
  • The backlog is bounded by a byte budget (max_bytes, fed from [replication] replication_buffer_size in config). When a new frame would exceed the budget, the oldest frames are dropped to make room.
  • Replicas that disconnect and reconnect within the backlog window resume via ReplicationSource::frames_from. Replicas that fall off the back of the buffer get Err(FromOffset::TooOld) and the caller initiates a full snapshot ship.

The source does not know about replicas — slot tracking lives in crate::slot::SlotTable. The source is a passive structure the streaming loop reads; mutation/serialisation lock policy is the wiring layer’s concern.

Structs§

Frame
One encoded mutation frame parked in the backlog.
FramesIter
Iterator over backlog frames returned by ReplicationSource::frames_from.
ReplicationSource
Bounded backlog of recent replicated mutations.

Enums§

FromOffset
Reason ReplicationSource::frames_from cannot serve a replica from the backlog.