Skip to main content

PrimaryMessage

Enum PrimaryMessage 

Source
pub enum PrimaryMessage {
    StreamStart {
        start_sequence: u64,
        segment_start_sequence: u64,
        anchor_hash: [u8; 32],
        epoch: u64,
        durability_mode: u8,
    },
    NeedSnapshot,
    HashMismatch,
    SnapshotBegin {
        snapshot_len: u64,
        snap_sequence: u64,
        snap_chain_hash: [u8; 32],
    },
    SnapshotChunk(Vec<u8>),
    SnapshotEnd {
        crc32c: u32,
    },
    Heartbeat {
        sequence: u64,
        durability_mode: u8,
    },
    Rotate {
        boundary_seq: u64,
        tail_hash: [u8; 32],
    },
    ChainCheck {
        sequence: u64,
        chain_hash: [u8; 32],
    },
    SegmentSeedBegin {
        seed_len: u64,
    },
}
Expand description

Messages from primary to replica.

Variants§

§

StreamStart

Fields

§start_sequence: u64
§segment_start_sequence: u64

Header identity for the journal segment a fresh replica should create before consuming the stream: the segment’s starting_sequence and chain anchor_hash. For full catch-up this is the primary’s oldest segment (lineage origin); after a snapshot transfer it is snap_sequence + 1 anchored to the snapshot’s chain hash. Replicas with existing local state ignore it.

§anchor_hash: [u8; 32]
§epoch: u64

The primary’s current fencing epoch. A replica that already observed a higher epoch refuses to follow this (stale) primary; a replica behind it adopts the epoch as the stream’s EpochBumps replay. See crate::fence.

§durability_mode: u8

The primary’s active durability (acking) mode, in the server-runtime DurabilityMode::as_u8 encoding — opaque at this layer. Refreshed by every Heartbeat; the replica’s auto-promotion refusal reads the last-observed value, so it judges the mode the dead primary actually acked under instead of its own locally-configured one.

§

NeedSnapshot

§

HashMismatch

§

SnapshotBegin

Start of a snapshot transfer. Sent after NeedSnapshot.

Fields

§snapshot_len: u64

Total snapshot file size in bytes.

§snap_sequence: u64

Journal sequence at which the snapshot was taken.

§snap_chain_hash: [u8; 32]

BLAKE3 chain hash at the snapshot point.

§

SnapshotChunk(Vec<u8>)

A chunk of snapshot data. Sent repeatedly after SnapshotBegin.

§

SnapshotEnd

End of snapshot transfer. Contains CRC32C of the entire snapshot file.

Fields

§crc32c: u32
§

Heartbeat

Fields

§sequence: u64
§durability_mode: u8

See StreamStart::durability_mode — heartbeats keep the replica’s view current across runtime DURABILITY retunes.

§

Rotate

Primary-driven segment rotation. Sent in-stream, after the last entry of the outgoing segment (boundary_seq) and before the first entry of the new one. The replica rotates its own journal at exactly this boundary, and tail_hash — the primary’s chain value at boundary_seq, which is also the new segment’s header anchor — doubles as a divergence check: a healthy replica’s own tail equals it. Replicas never rotate on local triggers; shared boundaries are what make chain values comparable across nodes (and healthy replica journals bitwise mirrors of the primary’s).

Fields

§boundary_seq: u64
§tail_hash: [u8; 32]
§

ChainCheck

Live-stream chain validation. chain_hash is the primary’s chain value at sequence (an fsync-batch boundary); the replica compares its own value at that sequence and treats a mismatch as divergence. Extends the handshake-time check to the live stream, catching corruption that creeps in mid-session.

Fields

§sequence: u64
§chain_hash: [u8; 32]
§

SegmentSeedBegin

Start of a segment-seed transfer: the raw byte prefix (file header through the snapshot’s last entry) of the primary segment containing snap_sequence + 1. Sent between the snapshot transfer and the post-snapshot StreamStart; the body rides SnapshotChunk frames and ends with a SnapshotEnd carrying the seed’s CRC32C. Writing it verbatim as the replica’s live segment makes the replica’s segmentation a byte-copy of the primary’s from birth, so chain values are comparable (and Rotate verification holds) with no alignment grace period.

Fields

§seed_len: u64

Total seed length in bytes (file header included).

Trait Implementations§

Source§

impl Debug for PrimaryMessage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> OptionalSend for T
where T: Send + ?Sized,

Source§

impl<T> OptionalSync for T
where T: Sync + ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more