Skip to main content

CascadeRelay

Struct CascadeRelay 

Source
pub struct CascadeRelay { /* private fields */ }
Expand description

Tracks the sub-replica slots an intermediate holds and the frontiers that must propagate through the chain. Pure bookkeeping — the forwarding transport calls into it to decide what to send and what to advertise upstream.

All LSN updates are monotonic: a stale ack or a duplicate forward can never rewind a frontier, which keeps retention safe under reordering and retries.

Implementations§

Source§

impl CascadeRelay

Source

pub fn new(node_id: impl Into<String>) -> Self

Source

pub fn node_id(&self) -> &str

Source

pub fn record_self_applied(&mut self, lsn: u64)

Record how far this intermediate has applied from its own upstream. Monotonic — a late report never rewinds the forward bound.

Source

pub fn self_applied_lsn(&self) -> u64

Source

pub fn register_downstream( &mut self, id: impl Into<String>, start_lsn: u64, ) -> u64

Hold a sub-replica’s slot, resuming it at start_lsn.

Idempotent on reconnect (issue #812 semantics): if the slot already exists its progress is preserved — only a forward start_lsn can advance confirmed_lsn, never rewind it — so a reconnecting sub-replica is not pushed backwards. Returns the LSN the sub-replica should resume streaming from (its retained confirmed position).

Source

pub fn unregister_downstream(&mut self, id: &str) -> bool

Release a sub-replica’s slot. Returns true if it was held. After this, the released sub-replica no longer pins the chain’s retention frontier.

Source

pub fn record_downstream_ack(&mut self, id: &str, lsn: u64)

Record a sub-replica’s confirmation that it has durably applied up to lsn. Monotonic. No-op for an unknown id.

Source

pub fn note_forwarded(&mut self, id: &str, lsn: u64)

Note that records up to lsn were forwarded to a sub-replica. Monotonic. No-op for an unknown id.

Source

pub fn downstream_ids(&self) -> Vec<String>

Source

pub fn downstream_slot(&self, id: &str) -> Option<&DownstreamSlot>

Source

pub fn downstream_count(&self) -> usize

Source

pub fn upstream_confirmed_lsn(&self) -> u64

The retention frontier this intermediate reports to its own upstream (the primary, or a further intermediate).

This is the crux of chain correctness: it is the minimum of what the intermediate has itself applied and what every sub-replica has confirmed. The upstream retains WAL at or above this point, so a slow leaf keeps the whole chain’s slot open — the primary never prunes a record some downstream node still needs.

With no sub-replicas the frontier is simply the intermediate’s own applied position (it behaves like an ordinary direct replica).

Source

pub fn upstream_confirmed_bookmark(&self, term: u64) -> CausalBookmark

The retention frontier as a causal bookmark, stamped with term. Lets the chain advertise its safe-to-prune point in the same token vocabulary causal reads use (ADR 0031).

Source

pub fn downstream_visible_frontier(&self, id: &str) -> Option<u64>

The highest LSN a given sub-replica can currently serve for a causal read — the minimum of the intermediate’s applied frontier and the sub-replica’s own confirmed position. Down the chain this is monotonically non-increasing, so a bookmark read routes to a node only if that node’s visible frontier covers the bookmark’s commit_lsn.

Returns None for an unknown sub-replica.

Source

pub fn downstream_can_serve(&self, id: &str, bookmark: &CausalBookmark) -> bool

Whether a sub-replica can satisfy a read at bookmark. True only when its visible frontier covers the bookmark’s commit LSN.

Source

pub fn records_to_forward<'a, T>( &self, requested_since_lsn: u64, available: &'a [(u64, T)], ) -> Vec<&'a (u64, T)>

Select the records to forward to a sub-replica from a batch the intermediate has on hand.

available is a slice of (lsn, payload) the intermediate has received from its own upstream, assumed ascending by LSN. The result keeps every record with requested_since_lsn < lsn <= self_applied_lsn — newer than what the sub-replica has, and not beyond what the intermediate itself holds. Records the intermediate has buffered but not yet applied are withheld, so a sub-replica never sees data ahead of its feeder.

Trait Implementations§

Source§

impl Clone for CascadeRelay

Source§

fn clone(&self) -> CascadeRelay

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CascadeRelay

Source§

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

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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