tail

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2021 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSkipSegment = errors.New("skip truncated WAL segment")
)

Functions

This section is empty.

Types

type Tailer

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

Tailer tails a write ahead log in a given directory.

func Tail

func Tail(ctx context.Context, logger log.Logger, dir string, promMon *prometheus.Monitor) (*Tailer, error)

Tail the prometheus/tsdb write ahead log in the given directory. Checkpoints are read before reading any WAL segments. Tailing may fail if we are racing with the DB itself in deleting obsolete checkpoints and segments. The caller should implement relevant logic to retry in those cases.

func (*Tailer) Close

func (t *Tailer) Close() error

Close all underlying resources of the tailer.

func (*Tailer) CurrentSegment

func (t *Tailer) CurrentSegment() int

CurrentSegment returns the index of the currently read segment. If no successful read has been performed yet, it may be negative.

func (*Tailer) Next

func (t *Tailer) Next()

func (*Tailer) Offset

func (t *Tailer) Offset() int

Offset returns the approximate current position of the tailer in the WAL with respect to Size().

func (*Tailer) Read

func (t *Tailer) Read(b []byte) (int, error)

func (*Tailer) SetNextSegment added in v0.23.1

func (t *Tailer) SetNextSegment(segment int)

Offset is reset as in incNextSegment() as we *just* started pointing to the *current* segment.

func (*Tailer) Size

func (t *Tailer) Size() (int, error)

Size returns the total size of the WAL as indicated by its highest segment. It includes the size of any past segments that may no longer exist.

type WalTailer added in v0.22.0

type WalTailer interface {
	Size() (int, error)
	Next()
	Offset() int
	Close() error
	CurrentSegment() int
	Read(b []byte) (int, error)
	SetNextSegment(int)
}

Jump to

Keyboard shortcuts

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