Documentation
¶
Index ¶
- type Binary
- type Entry
- type EntryDB
- type EntryIdx
- type EntryStore
- type EntryType
- type MemEntryStore
- func (s *MemEntryStore[T, E]) Append(entries ...E) error
- func (s *MemEntryStore[T, E]) Close() error
- func (s *MemEntryStore[T, E]) LastEntryIdx() EntryIdx
- func (s *MemEntryStore[T, E]) Read(idx EntryIdx) (E, error)
- func (s *MemEntryStore[T, E]) Size() int64
- func (s *MemEntryStore[T, E]) Truncate(idx EntryIdx) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Binary ¶ added in v1.9.5
type Binary[T EntryType, E Entry[T]] interface { Append(dest []byte, e *E) []byte ReadAt(dest *E, r io.ReaderAt, at int64) (n int, err error) EntrySize() int }
Binary is the binary interface to encode/decode/size entries. This should be a zero-cost abstraction, and is bundled as interface for the EntryDB to have generic access to this functionality without const-generics for array size in Go.
type Entry ¶
type Entry[T EntryType] interface { Type() T comparable }
type EntryDB ¶
type EntryDB[T EntryType, E Entry[T], B Binary[T, E]] struct { // contains filtered or unexported fields }
func NewEntryDB ¶
func NewEntryDB[T EntryType, E Entry[T], B Binary[T, E]](logger log.Logger, path string) (*EntryDB[T, E, B], 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[T, E, B]) Append ¶
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[T, E, B]) LastEntryIdx ¶
LastEntryIdx returns the index of the last entry in the DB. This returns -1 if the DB is empty.
type EntryStore ¶ added in v1.9.5
type MemEntryStore ¶ added in v1.9.5
func (*MemEntryStore[T, E]) Append ¶ added in v1.9.5
func (s *MemEntryStore[T, E]) Append(entries ...E) error
func (*MemEntryStore[T, E]) Close ¶ added in v1.9.5
func (s *MemEntryStore[T, E]) Close() error
func (*MemEntryStore[T, E]) LastEntryIdx ¶ added in v1.9.5
func (s *MemEntryStore[T, E]) LastEntryIdx() EntryIdx
func (*MemEntryStore[T, E]) Read ¶ added in v1.9.5
func (s *MemEntryStore[T, E]) Read(idx EntryIdx) (E, error)
func (*MemEntryStore[T, E]) Size ¶ added in v1.9.5
func (s *MemEntryStore[T, E]) Size() int64
func (*MemEntryStore[T, E]) Truncate ¶ added in v1.9.5
func (s *MemEntryStore[T, E]) Truncate(idx EntryIdx) error