Struct ShardCore
pub struct ShardCore {
pub shard: u32,
pub shards: u32,
pub retention_ms: u64,
/* private fields */
}Fields§
§shard: u32§shards: u32§retention_ms: u64Implementations§
§impl ShardCore
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
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)> + '_
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)
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
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
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
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)
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>)
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>
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>
pub fn next_timer(&self) -> Option<u64>
When the host should next call poll_timers.
pub fn poll_timers(&mut self, now_ms: u64)
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>
pub fn peek_event(&self) -> Option<&Event>
The next event without taking it.
pub fn reoffer(&mut self, run_id: RunId)
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,
)
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],
)
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>
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
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,
)
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>
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)
pub fn reserve_runs(&mut self, n: usize)
Makes room for n more runs (before loading an index).
pub fn index_loaded(&mut self)
pub fn index_loaded(&mut self)
After load_index: rebuilds the retention queue.
pub fn begin_index_snapshot(&mut self)
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>
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)
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
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>)
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
pub fn index_pending(&self) -> usize
Records pending for the next index delta.
pub fn journal_bytes(&self) -> usize
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
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>
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)
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
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)
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)
pub fn shrink(&mut self)
Releases capacity left behind when many runs were parked or finished (hash maps never shrink on their own).