wal

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package wal (Write-ahead logging) is an independent component to ensure data reliability.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct{}

Options for creating Write-ahead Logging.

type Segment

type Segment interface {
	GetSegmentID() SegmentID
}

Segment allows reading underlying segments that hold WAl entities.

type SegmentID

type SegmentID uint64

SegmentID identities a segment in a WAL.

type WAL

type WAL interface {
	// Write a logging entity.
	// It will return immediately when the data is written in the buffer,
	// The returned function will be called when the entity is flushed on the persistent storage.
	Write(seriesID common.SeriesID, timestamp time.Time, data []byte) (func(), error)
	// Read specified segment by SegmentID.
	Read(segmentID SegmentID) (*Segment, error)
	// ReadAllSegments reads all segments sorted by their creation time in ascending order.
	ReadAllSegments() ([]*Segment, error)
	// Rotate closes the open segment and opens a new one, returning the closed segment details.
	Rotate() (*Segment, error)
	// Delete the specified segment.
	Delete(segmentID SegmentID) error
}

WAL denotes a Write-ahead logging. Modules who want their data reliable could write data to an instance of WAL. A WAL combines several segments, ingesting data on a single opened one. Rotating the WAL will create a new segment, marking it as opened and persisting previous segments on the disk.

func New

func New(_ string, _ Options) (WAL, error)

New creates a WAL instance in the specified path.

Jump to

Keyboard shortcuts

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