Struct persist::file::FileLog[][src]

pub struct FileLog {
    base_dir: Option<PathBuf>,
    dataz: Arc<Mutex<FileLogCore>>,
    seqno: Range<SeqNo>,
    buf: Vec<u8>,
}
Expand description

A naive implementation of Log backed by files.

Fields

base_dir: Option<PathBuf>dataz: Arc<Mutex<FileLogCore>>seqno: Range<SeqNo>buf: Vec<u8>

Implementations

Returns a new FileLog which stores files under the given dir.

To ensure directory-wide mutual exclusion, a LOCK file is placed in base_dir at construction time. If this file already exists (indicating that another FileLog is already using the dir), an error is returned from new.

The contents of lock_info are stored in the LOCK file and should include anything that would help debug an unexpected LOCK file, such as version, ip, worker number, etc.

The data is stored in a separate file, and is formatted as a sequential list of chunks corresponding to each write. Each chunk consists of: length - A 64 bit unsigned int (little-endian) indicating the size of data. data - length bytes of data. sequence_number - A 64 bit unsigned int (little-endian) indicating the sequence number assigned to data.

Additionally, the metadata about the last truncated sequence number is stored in a metadata file, which only ever contains a single 64 bit unsigned integer (also little-endian) that indicates the most recently truncated offset (ie all offsets less than this are truncated).

Trait Implementations

Formats the value using the given formatter. Read more

Logically truncates the log so that future reads ignore writes at sequence numbers less than upper.

TODO: actually reclaim disk space as part of truncating.

Synchronously appends an entry. Read more

Returns a consistent snapshot of all written but not yet truncated entries. Read more

Synchronously closes the log, releasing exclusive-writer locks and causing all future commands to error. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more