Skip to main content

ShardCore

Struct ShardCore 

pub struct ShardCore {
    pub shard: u32,
    pub shards: u32,
    pub retention_ms: u64,
    /* private fields */
}

Fields§

§shard: u32§shards: u32§retention_ms: u64

Implementations§

§

impl ShardCore

pub fn new(shard: u32, shards: u32, retention_ms: u64, now_ms: u64) -> Self

pub fn next_run_id(&self) -> RunId

pub fn set_next_run_id(&mut self, next: RunId)

pub fn allocate_run(&mut self) -> RunId

Allocates a run ID for a Start record about to be appended.

pub fn find(&self, id: &str) -> Option<Found>

pub fn get(&self, run: RunId) -> Option<&LoadedRun>

pub fn parked(&self, run: RunId) -> Option<ParkedRun>

pub fn is_parked(&self, run: RunId) -> bool

pub fn chained_runs(&self) -> impl Iterator<Item = (RunId, BlobRef)> + '_

Parked runs whose frame is a Delta (compaction rewrites them whole).

pub fn reparked(&mut self, run: RunId, blob: BlobRef)

A parked run’s frame was rewritten whole at blob (before compaction).

pub fn loaded_runs(&self) -> impl Iterator<Item = (RunId, &LoadedRun)>

pub fn parked_runs(&self) -> impl Iterator<Item = (RunId, ParkedRun)> + '_

pub fn newest_first(&self) -> NewestFirst

A cursor over every run, loaded or parked, newest first (see NewestFirst).

pub fn loaded_len(&self) -> usize

pub fn parked_len(&self) -> usize

pub fn timers_len(&self) -> usize

pub fn table_bytes(&self) -> usize

Heap bytes of the run table, its indexes and the near wheel’s items.

pub fn seen_signal(&self, run: RunId, dedup: u64) -> bool

Whether a signal with this dedup key was already accepted.

pub fn add_output(&mut self, lsn: Lsn, output: Output)

Queue an output for the record at lsn (the most recent append).

pub fn release(&mut self, durable: Lsn, out: &mut Vec<Output>)

Outputs whose records are durable through durable.

pub fn pending_outputs(&self) -> usize

pub fn unreleased(&self) -> impl Iterator<Item = &Output>

Outputs not yet released (their records are not yet durable).

pub fn take_event(&mut self) -> Option<Event>

pub fn has_events(&self) -> bool

pub fn next_timer(&self) -> Option<u64>

When the host should next call poll_timers.

pub fn poll_timers(&mut self, now_ms: u64)

Fires due timers as events, at most TIMER_CHUNK per call.

pub fn peek_event(&self) -> Option<&Event>

The next event without taking it.

pub fn reoffer(&mut self, run_id: RunId)

Re-offers buffered signals to pending waits after recovery or load.

pub fn apply<S: ToName, B: ToPayload>( &mut self, lsn: Lsn, rec: &Record<S, B>, mode: Mode, )

Applies one record at lsn.

pub fn apply_encoded<S: ToName, B: ToPayload>( &mut self, lsn: Lsn, rec: &Record<S, B>, mode: Mode, canonical: &[u8], )

Self::apply for a record whose canonical encoding (crate::record::encode_canonical) the host already has: the journal copies it instead of encoding the record again.

pub fn park( &mut self, run_id: RunId, blob: BlobRef, chained: bool, ) -> Option<ParkedRun>

Moves a loaded run to the parked index. The host has written its journal to blob (chained: a Delta frame extending earlier ones).

pub fn shrink_spare(&mut self, keep: usize) -> usize

Frees spare containers beyond keep: a shard that loads and starts nothing keeps few, so a large parked population costs no pool. Returns how many it freed.

pub fn insert_parked( &mut self, run: RunId, blob: BlobRef, done: Option<Status>, chained: bool, id_hash: u64, time: u64, )

Restores a parked run (run store scan or persisted index at recovery). time: its earliest timer, or when it finished.

pub fn load_index(&mut self, records: &[u8]) -> Result<(), &'static str>

Applies persisted index records (see table::Entry::record): each sets a parked run, or removes it. Recovery reads the index frames named by the checkpoint this way, oldest first.

pub fn reserve_runs(&mut self, n: usize)

Makes room for n more runs (before loading an index).

pub fn index_loaded(&mut self)

After load_index: rebuilds the retention queue.

pub fn begin_index_snapshot(&mut self)

Starts a new base of the persisted index: clears the change lists. index_snapshot then lists every parked run.

pub fn index_snapshot( &mut self, from: Slot, max: usize, out: &mut Vec<u8>, ) -> Option<Slot>

Index records for up to max parked runs from slot from on, for a new base. Returns the slot to continue from (None: done).

pub fn hold_slots(&mut self, on: bool)

While on, shrink does not compact the run table, so every entry stays in its slot: an index base written over several calls of index_snapshot then visits every entry that was in the table when it began (entries added later land in a free or new slot and are in the change lists once they matter).

pub fn index_needs_base(&self) -> bool

The change lists overflowed: the next index write must be a base.

pub fn index_delta(&mut self, out: &mut Vec<u8>)

Index records for what changed since the last snapshot or delta.

pub fn index_pending(&self) -> usize

Records pending for the next index delta.

pub fn journal_bytes(&self) -> usize

Bytes of loaded runs’ in-memory journals.

pub fn unpark( &mut self, run_id: RunId, last_lsn: Lsn, blob_records: &[RecordBuf], now_ms: u64, ) -> bool

Loads a parked run from its decoded journal (last_lsn from its frame). If a timer of the run came due while it was parked, its due timers fire now.

pub fn next_expiry(&self) -> Option<u64>

Earliest time a completed run becomes eligible for removal, including after recovery.

pub fn relocate_blob(&mut self, run: RunId, offset: u64)

Update the frame location without losing a loaded journal’s suffix or timers.

pub fn expire(&mut self, now_ms: u64, out: &mut Vec<RunId>) -> u64

Remove expired runs and return the number of store bytes they occupied.

pub fn remove(&mut self, run: RunId)

Forgets a run entirely (terminated before it was ever parked, or a determinism failure the host gave up on). Rarely needed.

pub fn shrink(&mut self)

Releases capacity left behind when many runs were parked or finished (hash maps never shrink on their own).

pub fn spilled(&mut self, run: RunId, blob: BlobRef, chain: u64, depth: u8)

Replaces the journal of a loaded run after the host stored a prefix of it in the run store: blob is the newest frame, chain the bytes of it and the frames it extends, depth how many it extends.

pub fn set_blob(&mut self, run: RunId, blob: BlobRef, chain: u64, depth: u8)

A loaded run’s stored prefix moved to blob (its chain written whole), keeping the records after it in memory.

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, 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, 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.