Expand description
tickertape: a local, append-only event journal backed by memory-mapped segment files.
One Writer process appends records; any number of Readers, in the same or other processes on the same
host, follow the journal live or replay it from any sequence number. Records are opaque payload bytes with a
sequence number, a caller-defined schema id and two caller-supplied timestamps.
- The byte layout is specified in
docs/format.mdin the repository, and mirrored by theformatmodule. - What survives a process crash or power loss is specified in
docs/crash-contract.md. In short: a record is visible to readers, and survives the writer process dying, as soon asWriter::appendreturns; it is durable only after a laterWriter::checkpointreturns, or after a background checkpoint started withWriter::request_checkpointhas finished.
use tickertape::{NewRecord, Reader, ReaderConfig, Writer, WriterConfig};
let mut writer = Writer::open("/tmp/journal", WriterConfig::default())?;
let seq = writer.append(&NewRecord {
schema_id: 1,
venue_ts_ns: 0,
local_ts_ns: tickertape::clock::realtime_ns(),
payload: b"hello",
})?;
writer.checkpoint()?; // make it durable, not only visible
let mut reader = Reader::open("/tmp/journal", ReaderConfig::default())?;
reader.seek(seq)?;
if let Some(record) = reader.try_next()? {
assert_eq!(record.payload, b"hello");
}Modules§
- clock
- Helpers for caller-supplied timestamps.
- format
- The on-disk format (version 1), as pure functions over precisely bounded byte slices.
- inspect
- Read-only inspection and verification, used by the CLI (
tickertape inspect,tickertape verify). - retention
- Opt-in removal of a sealed, checkpoint-covered prefix of a journal (ADR 0016).
- status
- Operational metrics: how far the writer has got, how much a power loss would cost now, how much room is left on
the volume, and how far behind each reader is (ADR 0032;
docs/operations.md→ Monitoring).
Structs§
- Backoff
- How a reader waits for new records in
Reader::next_timeout. - Batch
Error Writer::append_batchstopped at a record it could not append.- Checkpoint
Progress - Where a writer’s checkpoints stand (
Writer::checkpoint_progress). - NewRecord
- A record to append. The writer assigns the sequence number.
- Owned
Record - A record copied out of the journal.
- Reader
- An independent cursor over a journal, in this or another process.
- Reader
Config - Reader settings.
- Record
- A committed, validated record, borrowed from the
Readerthat returned it. - Records
- Iterator returned by
Reader::records: owned records committed so far. - Recovery
Report - What
Writer::openfound and did. - Writer
- The only process allowed to append to a journal.
- Writer
Config - Writer settings. Construct with
WriterConfig::defaultand the builder methods.
Enums§
- Corrupt
Reason - Why bytes failed validation. See
docs/format.mdfor the rules. - Error
- Everything that can go wrong.
- Helper
Cpus - Where the writer’s helper threads run (
WriterConfig::helper_cpus). - Recovery
Action - One repair performed by
Writer::open. - Recovery
Policy - What the writer does on open when it finds corruption after the last checkpoint: an invalid record or seal, a
segment disconnected from the chain, an empty commit word after which recovery finds evidence of committed
history (
CorruptReason::EmptyCommitWord, orCorruptReason::UncheckedTailwhen its search stops at its work bound), or non-zero bytes after an empty commit word in front of a segment for the expected sequence number that exists but does not open (CorruptReason::BrokenChain;docs/crash-contract.md, C11, and ADR 0035 have the rules).
Constants§
- VERSION
- The version of this crate, as set in
Cargo.toml.
Type Aliases§
- Result
- Result type of all fallible tickertape operations.