Documentation
¶
Index ¶
Constants ¶
Variables ¶
var ErrInvalidCRC = errors.New("invalid CRC checksum")
var (
ErrReadingRecord = errors.New("error reading record")
)
Functions ¶
This section is empty.
Types ¶
type Creator ¶
type Creator func() (DeletableWAL, error)
Creator creates a DeletableWAL. Returns an error upon failure.
type DeletableWAL ¶
type DeletableWAL interface {
simplex.WriteAheadLog
// Delete deletes the WAL file and after it is called,
// it should no longer be used.
Delete() error
}
DeletableWAL is a WAL that can be deleted.
type GarbageCollectedWAL ¶
type GarbageCollectedWAL struct {
// contains filtered or unexported fields
}
func NewGarbageCollectedWAL ¶
func NewGarbageCollectedWAL(WALs []DeletableWAL, creator Creator, reader Reader, maxWALSize int) (*GarbageCollectedWAL, error)
NewGarbageCollectedWAL creates a new GarbageCollectedWAL. It takes in a list of existing WALs to load, a Creator to create new WALs, a Reader to read the retention term of entries, and a maximum WAL size. A new WAL is created when the given maximum WAL size of a WAL is reached.
func (*GarbageCollectedWAL) Append ¶
func (gcw *GarbageCollectedWAL) Append(payload []byte) error
func (*GarbageCollectedWAL) ReadAll ¶
func (gcw *GarbageCollectedWAL) ReadAll() ([][]byte, error)
func (*GarbageCollectedWAL) Truncate ¶
func (gcw *GarbageCollectedWAL) Truncate(retentionTerm uint64) error
type LastRecordStoringWAL ¶
type LastRecordStoringWAL struct {
TruncateableWAL
// contains filtered or unexported fields
}
func NewLastRecordStoringWAL ¶
func NewLastRecordStoringWAL(lastRecordFilePath string, innerWAL TruncateableWAL, recordType uint16) (*LastRecordStoringWAL, error)
NewLastRecordStoringWAL creates a new WAL that stores the last record of the given recordType. If the WAL is recentlyTruncated, the last record file is persisted to disk before the truncation takes place, and is thus saved even if the truncation removes all records of the given recordType.
func (*LastRecordStoringWAL) Append ¶
func (ri *LastRecordStoringWAL) Append(record []byte) error
func (*LastRecordStoringWAL) LastRecord ¶
func (ri *LastRecordStoringWAL) LastRecord() []byte
func (*LastRecordStoringWAL) Truncate ¶
func (ri *LastRecordStoringWAL) Truncate(retentionTerm uint64) error
type TruncateableWAL ¶
type TruncateableWAL interface {
DeletableWAL
Truncate(retentionTerm uint64) error
}
TruncateableWAL is a DeletableWAL that can be recentlyTruncated to a given retention term. It removes all entries below the given retention term.
type WriteAheadLog ¶
type WriteAheadLog struct {
// contains filtered or unexported fields
}
func New ¶
func New(fileName string) *WriteAheadLog
New opens a write ahead log file, creating one if necessary. Call Close() on the WriteAheadLog to ensure the file is closed after use.
func (*WriteAheadLog) Append ¶
func (w *WriteAheadLog) Append(b []byte) error
Appends a record to the write ahead log Must flush the OS cache on every append to ensure consistency
func (*WriteAheadLog) Close ¶
func (w *WriteAheadLog) Close() error
func (*WriteAheadLog) Delete ¶
func (w *WriteAheadLog) Delete() error
func (*WriteAheadLog) ReadAll ¶
func (w *WriteAheadLog) ReadAll() ([][]byte, error)