Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type WALOptions ¶
type WALOptions struct { // LogDir is where the wal logs will be stored LogDir string // Maximum size in bytes for each file MaxLogSize int64 // The entire wal is broken down into smaller segments. // This will be helpful during log rotation and management // maximum number of log segments MaxSegments int MaxWaitBeforeSync time.Duration SyncMaxBytes int64 Log *zap.Logger }
type WriteAheadLog ¶
type WriteAheadLog struct {
// contains filtered or unexported fields
}
A Write Ahead Log (WAL) is a data structure used to record changes to a database or any persistent storage system in a sequential and durable manner. This allows for crash recovery and data integrity.
func NewWriteAheadLog ¶
func NewWriteAheadLog(opts *WALOptions) (*WriteAheadLog, error)
NewWriteAheadLog creates a new instance of the WriteAheadLog with the provided options.
func (*WriteAheadLog) Close ¶
func (wal *WriteAheadLog) Close() error
Close closes the underneath storage file, it flushes data remaining in the memory buffer and file systems in-memory copy of recently written data to file to ensure persistent commit of the log
func (*WriteAheadLog) GetOffset ¶
func (wal *WriteAheadLog) GetOffset() int64
GetOffset returns the current log offset.
func (*WriteAheadLog) Replay ¶
func (wal *WriteAheadLog) Replay(offset int64, f func([]byte) error) error
Replay replays log entries starting from the specified offset, invoking the provided callback.
func (*WriteAheadLog) Sync ¶ added in v0.0.4
func (wal *WriteAheadLog) Sync() error
Sync writes all the data to the disk ensuring data durability. Since it is a expensive call, calling this often will slow down the throughput.