Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Segment ¶
type Segment[T any] struct { // contains filtered or unexported fields }
Segment is a collection of records that exist in the WAL, in the order they were appended. The WAL will append a maximum of maxSegmentSize records to a segment before cutting a new one.
type WAL ¶
type WAL[T any] struct { // contains filtered or unexported fields }
WAL is a simple write-ahead-log like structure containing multiple records. It is rooted at a specific directory, which contains WAL segments as files. Each file is named with a ULID for the segment based on the timestamp the segment was created. Segments contain a maximum of maxSegmentSize records, and segments are automatically added as new records are appended to the log, as well as removed as segments are successfully processed.
func Open ¶
Open constructs a new WAL by loading segments from the specified directory. Directories and files that are not named with a valid ULID are ignored. Each segment is loaded in order based on the timestamp the segment was created, which is embedded in the ID of the segment.
func (*WAL[T]) Append ¶
Append adds the specified value to the WAL, creating a new segment if required. Once the record is appended to the tail of the WAL, the segment containing it is committed to disk.