Skip to main content

JsonlLedger

Struct JsonlLedger 

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

The durable Ledger. See the module doc for the contract.

Implementations§

Source§

impl JsonlLedger

Source

pub fn append_all( &mut self, drafts: Vec<EventDraft>, ) -> Result<Vec<EventRef>, StorageError>

Group commit: one durability barrier for the whole wave (crates/storage/Spec.lean §3, item 1: the batch is what the wave delivered).

Source

pub fn hand_off_session_slices(&mut self) -> Option<Sessions>

Hands this ledger’s session slices to whoever will file them from now on; this writer files none after it. None for a ledger that is not a city’s, and for one that already handed them off (crates/storage/spec/Sessions.lean §8-24).

Source

pub fn position(&self) -> Seq

The position a record written now would take.

A position, never content: this is what anchors a diagnostic log line to the only history (docs/logging.md section 4), and a reader accessor that returned records would invite decision logic to consult the ledger it is in the middle of writing.

Source

pub fn observe(&mut self, sink: WriteObserver)

Installs the write-path observer, replacing any earlier one. The sink runs on the appending thread after durability, so it must not block; a bounded send that drops on lag is the shape this expects.

Source

pub fn read_raw_lines(&self) -> Result<Vec<Vec<u8>>, StorageError>

The read face for replay, fixtures and inspection: every canonical line (no terminators), segments flattened in order.

Source§

impl JsonlLedger

Source

pub fn open(dir: &Path, now: TimeMs) -> Result<(Self, OpenReport), StorageError>

Production entrance: std filesystem underneath, and the ledger directory’s writer lock, taken before anything is read or repaired and held for as long as the returned ledger lives.

§Errors

LedgerHeld when another writer holds this ledger, in this process or another; otherwise whatever reading and repairing the segments reports.

Source

pub fn open_reusing( dir: &Path, now: TimeMs, records: &ProofRecords, ) -> Result<(Self, OpenReport), StorageError>

JsonlLedger::open, with the last segment’s verified-prefix record in records standing in for checking its prefix line by line when the record holds (crates/storage/spec/Jsonl.lean §8-34). Records are read, never written: the proof that holds the writer lock writes them.

§Errors

Those of JsonlLedger::open.

Source§

impl JsonlLedger

Source

pub fn halt_on(&mut self, halt: ChainHalt)

Share halt with this writer: every later append_all asks it before framing a line.

Source

pub fn await_verdict(&self)

Blocks until the proof this writer waits for has a verdict.

Source

pub fn admits(&self) -> Result<(), StorageError>

Whether this writer takes a line now, asked before a caller does anything a refused line would leave behind.

§Errors

Unproven before the verdict of a proof this writer awaits; ChainHalted after a broken one.

Source§

impl JsonlLedger

Source

pub fn proof_records(&self, dir: &Path) -> ProofRecords

The records of this ledger’s proofs, kept in dir: writable when this handle holds the ledger’s writer lock, read-only otherwise.

Trait Implementations§

Source§

impl Ledger for JsonlLedger

Source§

fn append_all( &mut self, drafts: Vec<EventDraft>, ) -> Result<Vec<EventRef>, AxError>

One buffer, one write and one barrier for the whole wave.

Source§

fn append(&mut self, draft: EventDraft) -> Result<EventRef, AxError>

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.