wal

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package wal implements write-ahead-log.

Index

Constants

View Source
const (
	IEEE            = 0xedb88320
	EntryHeaderSize = 28
	SegmentPrefix   = "segment"
)

Variables

This section is empty.

Functions

func NewWALStores

func NewWALStores(vertexInstance *dfv1.VertexInstance, opts ...Option) store.StoreProvider

Types

type Option

type Option func(stores *walStores)

func WithMaxBufferSize

func WithMaxBufferSize(size int64) Option

WithMaxBufferSize sets the WAL buffer max size option

func WithStorePath

func WithStorePath(path string) Option

WithStorePath sets the WAL store path

func WithSyncDuration

func WithSyncDuration(maxDuration time.Duration) Option

WithSyncDuration sets the WAL sync duration option

type WAL

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

WAL implements a write-ahead-log. It represents both reader and writer. This WAL is write heavy and read is infrequent, meaning a read will only happen during a boot up. WAL will only have one segment since these are relatively short-lived.

func (*WAL) Close

func (w *WAL) Close() (err error)

Close closes the WAL Segment.

func (*WAL) IsCorrupted

func (w *WAL) IsCorrupted() bool

IsCorrupted checks whether the file is corrupt

func (*WAL) Read

func (w *WAL) Read(size int64) ([]*isb.ReadMessage, bool, error)

func (*WAL) Write

func (w *WAL) Write(message *isb.ReadMessage) (err error)

Write writes the message to the WAL. The format as follow is

+-------------------+----------------+-----------------+--------------+----------------+
| watermark (int64) | offset (int64) | msg-len (int64) | CRC (unit32) | message []byte |
+-------------------+----------------+-----------------+--------------+----------------+

CRC will be used for detecting ReadMessage corruptions.

Jump to

Keyboard shortcuts

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