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
Auto Trait Implementations
impl RefUnwindSafe for FileLog
impl UnwindSafe for FileLog
Blanket Implementations
Mutably borrows from an owned value. Read more
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