wal

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2025 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RotationModeTime  = "time"
	RetentionModeTime = "time"
	WALModeUnbuffered = "unbuffered"
)
View Source
const (
	CRCSize = 4
)

Variables

View Source
var File_internal_wal_wal_proto protoreflect.FileDescriptor

Functions

func InitBG

func InitBG(wl AbstractWAL)

func MustMarshal

func MustMarshal(entry *WALEntry) []byte

Marshals

func MustUnmarshal

func MustUnmarshal(data []byte, entry *WALEntry)

func ShutdownBG

func ShutdownBG()

Types

type AOF

type AOF struct {
	// contains filtered or unexported fields
}

func NewAOFWAL

func NewAOFWAL(directory string) (*AOF, error)

func (*AOF) Close

func (wal *AOF) Close() error

Close the WAL file. It also calls Sync() on the WAL.

func (*AOF) ForEachCommand

func (wal *AOF) ForEachCommand(entry *WALEntry, callback func(*WALEntry) error) error

func (*AOF) Init

func (wal *AOF) Init(t time.Time) error

func (*AOF) LogCommand

func (wal *AOF) LogCommand(data []byte) error

WriteEntry writes an entry to the WAL.

func (*AOF) Replay

func (wal *AOF) Replay(callback func(*WALEntry) error) error

func (*AOF) Sync

func (wal *AOF) Sync() error

Writes out any data in the WAL's in-memory buffer to the segment file. If fsync is enabled, it also calls fsync on the segment file.

type AbstractWAL

type AbstractWAL interface {
	LogCommand([]byte) error
	Close() error
	Init(t time.Time) error
	Replay(c func(*WALEntry) error) error
	ForEachCommand(e *WALEntry, c func(*WALEntry) error) error
}

type WALEntry

type WALEntry struct {
	Version           string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"`                                                 // Version of the WAL entry (e.g., "v1.0")
	LogSequenceNumber uint64 `protobuf:"varint,2,opt,name=log_sequence_number,json=logSequenceNumber,proto3" json:"log_sequence_number,omitempty"` // Log Sequence Number (LSN)
	Data              []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`                                                       // The actual data being logged
	Crc32             uint32 `protobuf:"varint,4,opt,name=crc32,proto3" json:"crc32,omitempty"`                                                    // Cyclic Redundancy Check for integrity
	Timestamp         int64  `protobuf:"varint,5,opt,name=timestamp,proto3" json:"timestamp,omitempty"`                                            // Timestamp for the WAL entry (epoch time in nanoseconds)
	// contains filtered or unexported fields
}

func (*WALEntry) Descriptor deprecated

func (*WALEntry) Descriptor() ([]byte, []int)

Deprecated: Use WALEntry.ProtoReflect.Descriptor instead.

func (*WALEntry) GetCrc32

func (x *WALEntry) GetCrc32() uint32

func (*WALEntry) GetData

func (x *WALEntry) GetData() []byte

func (*WALEntry) GetLogSequenceNumber

func (x *WALEntry) GetLogSequenceNumber() uint64

func (*WALEntry) GetTimestamp

func (x *WALEntry) GetTimestamp() int64

func (*WALEntry) GetVersion

func (x *WALEntry) GetVersion() string

func (*WALEntry) ProtoMessage

func (*WALEntry) ProtoMessage()

func (*WALEntry) ProtoReflect

func (x *WALEntry) ProtoReflect() protoreflect.Message

func (*WALEntry) Reset

func (x *WALEntry) Reset()

func (*WALEntry) String

func (x *WALEntry) String() string

type WALNull

type WALNull struct {
}

func NewNullWAL

func NewNullWAL() (*WALNull, error)

func (*WALNull) Close

func (w *WALNull) Close() error

func (*WALNull) ForEachCommand

func (w *WALNull) ForEachCommand(entry *WALEntry, callback func(*WALEntry) error) error

func (*WALNull) Init

func (w *WALNull) Init(t time.Time) error

func (*WALNull) LogCommand

func (w *WALNull) LogCommand(b []byte) error

LogCommand serializes a WALLogEntry and writes it to the current WAL file.

func (*WALNull) Replay

func (w *WALNull) Replay(callback func(*WALEntry) error) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL