file

package
v0.0.0-...-8a7ea67 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package file implements a simple file storage layer for an index to operate on. The Store object implements the store.Storer interface, which is used by higher level index constructs. Note: in log file an entry is represented as -> <size><data> where size is a uint32 encoded in little endian to 4 bytes, storing the length in bytes of data, and data is a pb.Entry marshaled to bytes A log file looks like: <size><data><size><data>...<size><data><size><data>

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store provides operations for persisting to a file and reading data back. It implements the storage.Storer interface.

func NewStore

func NewStore(log *logrus.Logger, file string, opts ...StoreOption) (*Store, error)

NewStore returns a new Store object or an error. It accepts a file and options for overriding default behavior.

func (*Store) Append

func (s *Store) Append(e *pb.Entry) (int64, error)

Append writes to the tail of the storage file and returns the written entry's position or an error.

func (*Store) Begin

func (s *Store) Begin() storage.ForwardIterator

Begin returns an iterator to the beginning of the storage log.

func (*Store) Cleanup

func (s *Store) Cleanup() error

Cleanup is a utility for testing that closes and removes the file. NOTE: This should be unexported in the future.

func (*Store) Close

func (s *Store) Close() error

Close calls the underlying files Close method and stops the sync process.

func (*Store) ReadAt

func (s *Store) ReadAt(position int64) (*pb.Entry, error)

ReadAt reads and decodes the entry at position. It returns the entry or an error.

type StoreOption

type StoreOption func(*options)

StoreOption is func that modifies the store's configuration options.

func SyncInterval

func SyncInterval(dur time.Duration) StoreOption

SyncInterval overrides the Index default sync interval.

Jump to

Keyboard shortcuts

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