pub struct JsonlLedger { /* private fields */ }Expand description
The durable Ledger. See the module doc for the contract.
Implementations§
Source§impl JsonlLedger
impl JsonlLedger
Sourcepub fn append_all(
&mut self,
drafts: Vec<EventDraft>,
) -> Result<Vec<EventRef>, StorageError>
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).
Sourcepub fn hand_off_session_slices(&mut self) -> Option<Sessions>
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).
Sourcepub fn position(&self) -> Seq
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.
Sourcepub fn observe(&mut self, sink: WriteObserver)
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.
Sourcepub fn read_raw_lines(&self) -> Result<Vec<Vec<u8>>, StorageError>
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
impl JsonlLedger
Sourcepub fn open(dir: &Path, now: TimeMs) -> Result<(Self, OpenReport), StorageError>
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.
Sourcepub fn open_reusing(
dir: &Path,
now: TimeMs,
records: &ProofRecords,
) -> Result<(Self, OpenReport), StorageError>
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
impl JsonlLedger
Sourcepub fn halt_on(&mut self, halt: ChainHalt)
pub fn halt_on(&mut self, halt: ChainHalt)
Share halt with this writer: every later append_all asks it
before framing a line.
Sourcepub fn await_verdict(&self)
pub fn await_verdict(&self)
Blocks until the proof this writer waits for has a verdict.
Source§impl JsonlLedger
impl JsonlLedger
Sourcepub fn proof_records(&self, dir: &Path) -> ProofRecords
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.