Skip to main content

Crate tickertape

Crate tickertape 

Source
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.md in the repository, and mirrored by the format module.
  • 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 as Writer::append returns; it is durable only after a later Writer::checkpoint returns, or after a background checkpoint started with Writer::request_checkpoint has 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.
BatchError
Writer::append_batch stopped at a record it could not append.
CheckpointProgress
Where a writer’s checkpoints stand (Writer::checkpoint_progress).
NewRecord
A record to append. The writer assigns the sequence number.
OwnedRecord
A record copied out of the journal.
Reader
An independent cursor over a journal, in this or another process.
ReaderConfig
Reader settings.
Record
A committed, validated record, borrowed from the Reader that returned it.
Records
Iterator returned by Reader::records: owned records committed so far.
RecoveryReport
What Writer::open found and did.
Writer
The only process allowed to append to a journal.
WriterConfig
Writer settings. Construct with WriterConfig::default and the builder methods.

Enums§

CorruptReason
Why bytes failed validation. See docs/format.md for the rules.
Error
Everything that can go wrong.
HelperCpus
Where the writer’s helper threads run (WriterConfig::helper_cpus).
RecoveryAction
One repair performed by Writer::open.
RecoveryPolicy
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, or CorruptReason::UncheckedTail when 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.