log

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Segment struct {
		MaxStoreBytes uint64
		MaxIndexBytes uint64
		InitialOffset uint64
	}
}

Config centralizes the configuration for the log

type Log

type Log struct {
	Dir    string
	Config Config
	// contains filtered or unexported fields
}

Log consists of a list of segments and a pointer to the active segment to append writes to.

func NewLog

func NewLog(dir string, c Config) (*Log, error)

NewLog sets defaults for any configs the caller didn't set, then it creates a log instance, and sets up that instance

func (*Log) Append

func (l *Log) Append(record *api.Record) (uint64, error)

Append appends a record to the active segment of the log. If the segment is at its max size (per the config), a new segment is made. A RWMutex is used to grant access to reads when there isn't a write holding the lock. TODO optimize locks per segment, rather than entire log.

func (*Log) Close

func (l *Log) Close() error

Close iterates of the segments and closes them.

func (*Log) HighestOffset

func (l *Log) HighestOffset() (uint64, error)

HighestOffset returns the highest offset stored

func (*Log) LowestOffset

func (l *Log) LowestOffset() (uint64, error)

LowestOffset returns the lowest offset stored

func (*Log) Read

func (l *Log) Read(off uint64) (*api.Record, error)

Read reads the record at the given offset

func (*Log) Reader

func (l *Log) Reader() io.Reader

Reader returns an io.Reader to read the entire log.

func (*Log) Remove

func (l *Log) Remove() error

Remove closes the log and then removes the data.

func (*Log) Reset

func (l *Log) Reset() error

Reset removes the log and then creates a new log to replace it.

func (*Log) Truncate

func (l *Log) Truncate(lowest uint64) error

Truncate removes all segments whose highest offset is lower than lowest.

Jump to

Keyboard shortcuts

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