wal

package
v0.0.0-...-53619cb Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCorrupt    = errors.New("log corrupt")
	ErrClosed     = errors.New("log closed")
	ErrInvaildCRC = errors.New("invaild crc")
	ErrNotFound   = errors.New("not found")
	ErrEOF        = errors.New("end of file reached")
	ErrFailedLock = errors.New("failed to get file lock")
)
View Source
var DefaultOptions = &Options{
	NoSync:       false,
	SyncDuration: time.Second,
	SegmentSize:  20971520,
	DirPerms:     0750,
	FilePerms:    0640,
}

Functions

func WithAtomic

func WithAtomic(opt *logOption)

func WithSync

func WithSync(opt *logOption)

Types

type Batch

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

func (*Batch) Clear

func (b *Batch) Clear()

func (*Batch) Write

func (b *Batch) Write(data []byte)

type Log

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

Log represents a append only log

func Open

func Open(path string, opts *Options) (*Log, error)

func (*Log) Close

func (l *Log) Close() error

func (*Log) Flush

func (l *Log) Flush() error

func (*Log) Read

func (l *Log) Read(segment, index uint64) (data []byte, err error)

func (*Log) RunSync

func (l *Log) RunSync(duration time.Duration) error

func (*Log) Segments

func (l *Log) Segments() int

func (*Log) Sync

func (l *Log) Sync() error

func (*Log) Truncate

func (l *Log) Truncate(n int) error

func (*Log) Write

func (l *Log) Write(data []byte, opts ...LogOpition) (int, error)

func (*Log) WriteBatch

func (l *Log) WriteBatch(b *Batch, opts ...LogOpition) (int, error)

type LogOpition

type LogOpition func(*logOption)

type Options

type Options struct {
	// NoSync disables fsync after writes. This is less durable and puts the
	// log at risk of data loss when there's a server crash.
	NoSync       bool
	LoadAll      bool
	SyncDuration time.Duration
	SegmentSize  int // SegmentSize of each segment. Default is 20 MB.
	DirPerms     os.FileMode
	FilePerms    os.FileMode
}

Jump to

Keyboard shortcuts

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