entrydb

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EntrySize = 24
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry [EntrySize]byte

type EntryDB

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

func NewEntryDB

func NewEntryDB(logger log.Logger, path string) (*EntryDB, error)

NewEntryDB creates an EntryDB. A new file will be created if the specified path does not exist, but parent directories will not be created. If the file exists it will be used as the existing data. Returns ErrRecoveryRequired if the existing file is not a valid entry db. A EntryDB is still returned but all operations will return ErrRecoveryRequired until the Recover method is called.

func (*EntryDB) Append

func (e *EntryDB) Append(entries ...Entry) error

Append entries to the database. The entries are combined in memory and passed to a single Write invocation. If the write fails, it will attempt to truncate any partially written data. Subsequent writes to this instance will fail until partially written data is truncated.

func (*EntryDB) Close

func (e *EntryDB) Close() error

func (*EntryDB) LastEntryIdx

func (e *EntryDB) LastEntryIdx() EntryIdx

func (*EntryDB) Read

func (e *EntryDB) Read(idx EntryIdx) (Entry, error)

Read an entry from the database by index. Returns io.EOF iff idx is after the last entry.

func (*EntryDB) Size

func (e *EntryDB) Size() int64

func (*EntryDB) Truncate

func (e *EntryDB) Truncate(idx EntryIdx) error

Truncate the database so that the last retained entry is idx. Any entries after idx are deleted.

type EntryIdx

type EntryIdx int64

Jump to

Keyboard shortcuts

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