wal

package
v0.0.0-...-1be9e8e Latest Latest
Warning

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

Go to latest
Published: May 13, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxRecordBytes is the largest size a single record can be.
	MaxRecordBytes uint32 = 100 * 1024 * 1024
)

Variables

This section is empty.

Functions

func CleanUnusedFiles

func CleanUnusedFiles(dirname string, appliedUntil int64)

CleanUnusedFiles cleans unused log files, i.e those that have already been applied.

Types

type Options

type Options struct {
	Dirname    string
	TargetSize int64
}

type Scanner

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

Scanner reads log records from a write ahead log directory. Not thread-safe.

func NewScanner

func NewScanner(dirname string) (*Scanner, error)

NewScanner returns a log scanner over all the log files found in dirname. Returns ErrNotExist if there are no log files.

func (*Scanner) Err

func (s *Scanner) Err() error

Err returns last error, if any.

func (*Scanner) Record

func (s *Scanner) Record() *pb.LogRecord

Record returns the current record. Only valid until the next Scan() call. Caller should not modify returned proto.

func (*Scanner) Scan

func (s *Scanner) Scan() bool

Scan advances the fileScanner to the next log record, which will then be available through the Record method. It returns false when the scan stops, either by reaching the end of all logs or on error.

type Writer

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

Writer writes log entries to the write ahead log. Thread-safe.

func NewWriter

func NewWriter(nextSeq int64, opts Options) (*Writer, error)

func (*Writer) Append

func (w *Writer) Append(l *pb.LogRecord, cb func(error))

Append appends a log record to the WAL. The log record is modified with the log sequence number. cb is invoked serially, in log sequence number order.

func (*Writer) Close

func (w *Writer) Close() error

Jump to

Keyboard shortcuts

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