class

Raft::Log::Segment(T)

Inherits Reference < Object

Constructors

new(dir : String, first_index : UInt64)
Source
open(dir : String, first_index : UInt64) : self
Source

Instance methods

append(entry : LogEntry(T))
Source
byte_range_for(index : UInt64) : Tuple(UInt64, UInt32)

Byte range within this segment file occupied by the entry at index. Returns {offset, length}.

Source
close
Source
count
Source
fd

Underlying file descriptor. Exposed for future zero-copy senders (sendfile/splice/io_uring).

Source
first_index
Source
last_index
Source
read(index : UInt64) : LogEntry(T)
Source
size
Source
sync

Push buffered writes to the kernel page cache, then flush page cache to the device. Called at Raft durability boundaries (see Node#propose, Node#handle_append_entries, etc.). Two syscalls (write + fsync) per call.

Source
truncate_to(index : UInt64)
Source