wal

package
v0.0.0-...-c840629 Latest Latest
Warning

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

Go to latest
Published: May 28, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	B  = 1
	KB = 1024 * B
	MB = 1024 * KB
	GB = 1024 * MB
)

Variables

View Source
var (
	ErrWalNextOffset = errors.New("wal next offset out of range")
	ErrWalFSync      = walfs.ErrFsync
	ErrNoNewData     = walfs.ErrNoNewData
)

Functions

This section is empty.

Types

type Config

type Config struct {
	BytesPerSync uint32 `toml:"bytes_per_sync"`
	SegmentSize  int64  `toml:"segment_size"`
	// should fsync be done after every writes.
	// FSync are costly
	// writes are buffered to OS.
	// Logs will be only lost, if the machine itself crashes.
	// Not the process, data will be still safe as os buffer persists.
	FSync bool `toml:"fsync"`
	// call FSync with at this interval.
	SyncInterval    time.Duration `toml:"sync_interval"`
	AutoCleanup     bool          `toml:"auto_cleanup"`
	MaxAge          time.Duration `toml:"max_age"`
	MinSegment      int           `toml:"min_segment"`
	MaxSegment      int           `toml:"max_segment"`
	CleanupInterval time.Duration `toml:"cleanup_interval"`
}

Config stores all tunable parameters for WAL.

func NewDefaultConfig

func NewDefaultConfig() *Config

type Offset

type Offset = walfs.RecordPosition

Offset is a type alias to underlying wal implementation.

func DecodeOffset

func DecodeOffset(b []byte) *Offset

type Reader

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

func (*Reader) Close

func (r *Reader) Close()

func (*Reader) Next

func (r *Reader) Next() ([]byte, Offset, error)

Next returns the next chunk data and its position in the WAL. If there is no data, io. EOF will be returned. The position can be used to read the data from the segment file.

type ReaderOption

type ReaderOption func(*Reader)

func WithActiveTail

func WithActiveTail(enabled bool) ReaderOption

type SegID

type SegID = walfs.SegmentID

type WalIO

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

WalIO provides a write and read to underlying file based wal store.

func NewWalIO

func NewWalIO(dirname, namespace string, config *Config) (*WalIO, error)

func (*WalIO) Append

func (w *WalIO) Append(data []byte) (*Offset, error)

func (*WalIO) Close

func (w *WalIO) Close() error

func (*WalIO) GetTransactionRecords

func (w *WalIO) GetTransactionRecords(startOffset *Offset) ([]*logrecord.LogRecord, error)

GetTransactionRecords returns all the WalRecord that is part of the particular Txn.

func (*WalIO) NewReader

func (w *WalIO) NewReader(options ...ReaderOption) (*Reader, error)

NewReader returns a new instance of WIOReader, allowing the caller to access WAL logs for replication, recovery, or log processing.

func (*WalIO) NewReaderWithStart

func (w *WalIO) NewReaderWithStart(offset *Offset, options ...ReaderOption) (*Reader, error)

NewReaderWithStart returns a new instance of WIOReader from the provided Offset.

func (*WalIO) Read

func (w *WalIO) Read(pos *Offset) ([]byte, error)

func (*WalIO) RunWalCleanup

func (w *WalIO) RunWalCleanup(ctx context.Context, interval time.Duration, predicate walfs.DeletionPredicate)

func (*WalIO) Sync

func (w *WalIO) Sync() error

Sync Flushes the wal using fsync.

Jump to

Keyboard shortcuts

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