stores

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: MIT Imports: 18 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 {
	Path     string
	InMemory bool

	SyncWrites bool

	MaxLevels           int
	LevelSizeMultiplier int
	BaseTableSize       int64
	BaseLevelSize       int64
	ValueLogFileSize    int64
	ValueLogMaxEntries  uint32

	NumMemtables int
	MemTableSize int64

	BlockSize      int
	BlockCacheSize int64

	NumLevelZeroTables      int
	NumLevelZeroTablesStall int
	NumCompactors           int
	CompactL0OnClose        bool

	Compression bool

	GCEnabled      bool
	GCInterval     time.Duration
	GCDiscardRatio float64

	Logger Logger
}

func DefaultDataStoreConfig

func DefaultDataStoreConfig(path string, inmem bool) *Config

func DefaultLogStoreConfig

func DefaultLogStoreConfig(path string, inmem bool) *Config

type DataStore

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

func NewDataStore

func NewDataStore(config *Config) (*DataStore, error)

func (*DataStore) Apply

func (s *DataStore) Apply(log *raft.Log) any

func (*DataStore) Close

func (s *DataStore) Close() error

func (*DataStore) Delete

func (s *DataStore) Delete(key []byte) error

func (*DataStore) DeleteAll

func (s *DataStore) DeleteAll() error

func (*DataStore) DeleteMany

func (s *DataStore) DeleteMany(keys [][]byte) error

func (*DataStore) DeletePrefix

func (s *DataStore) DeletePrefix(prefix []byte) error

func (*DataStore) DeleteRange

func (s *DataStore) DeleteRange(min, max []byte) (keys [][]byte, err error)

func (*DataStore) Get

func (s *DataStore) Get(key []byte) ([]byte, error)

func (*DataStore) GetMany

func (s *DataStore) GetMany(keys [][]byte) ([][]byte, error)

func (*DataStore) GetPrefix

func (s *DataStore) GetPrefix(prefix []byte) (keys, values [][]byte, err error)

func (*DataStore) GetRange

func (s *DataStore) GetRange(min, max []byte, count int) (keys, values [][]byte, err error)

func (*DataStore) Restore

func (s *DataStore) Restore(r io.ReadCloser) error

func (*DataStore) Set

func (s *DataStore) Set(key, value []byte) error

func (*DataStore) SetMany

func (s *DataStore) SetMany(keys, values [][]byte) error

func (*DataStore) Snapshot

func (s *DataStore) Snapshot() (raft.FSMSnapshot, error)

func (*DataStore) Stats

func (s *DataStore) Stats() map[string]string

type LogStore

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

func NewLogStore

func NewLogStore(config *Config) (*LogStore, error)

func (*LogStore) Close

func (s *LogStore) Close() error

func (*LogStore) DeleteAll

func (s *LogStore) DeleteAll() error

DeleteAll deletes all log entries.

func (*LogStore) DeleteRange

func (s *LogStore) DeleteRange(min, max uint64) error

DeleteRange deletes a range of log entries. The range is inclusive.

func (*LogStore) FirstIndex

func (s *LogStore) FirstIndex() (uint64, error)

FirstIndex returns the first index written. 0 for no entries.

func (*LogStore) GetLog

func (s *LogStore) GetLog(index uint64, log *raft.Log) error

GetLog gets a log entry at a given index.

func (*LogStore) LastIndex

func (s *LogStore) LastIndex() (uint64, error)

LastIndex returns the last index written. 0 for no entries.

func (*LogStore) Stats

func (s *LogStore) Stats() map[string]string

func (*LogStore) StoreLog

func (s *LogStore) StoreLog(log *raft.Log) error

StoreLog stores a log entry.

func (*LogStore) StoreLogs

func (s *LogStore) StoreLogs(logs []*raft.Log) error

StoreLogs stores multiple log entries.

type Logger

type Logger interface {
	Errorf(string, ...any)
	Warningf(string, ...any)
	Infof(string, ...any)
	Debugf(string, ...any)
}

type StableStore

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

StableStore is used to provide stable storage of key configurations to raft consensus algorithm.

func NewStableStore

func NewStableStore(config *StableStoreConfig) (*StableStore, error)

func (*StableStore) Close

func (s *StableStore) Close()

func (*StableStore) Get

func (s *StableStore) Get(key []byte) ([]byte, error)

Get returns the value for key, or an empty byte slice if key was not found.

func (*StableStore) GetUint64

func (s *StableStore) GetUint64(key []byte) (uint64, error)

GetUint64 returns the uint64 value for key, or 0 if key was not found.

func (*StableStore) PrintConfig

func (s *StableStore) PrintConfig(out io.Writer)

func (*StableStore) Set

func (s *StableStore) Set(key []byte, val []byte) error

func (*StableStore) SetUint64

func (s *StableStore) SetUint64(key []byte, val uint64) error

type StableStoreConfig

type StableStoreConfig struct {
	Path     string // Config directory path.
	Sync     bool   // Fsync after each write.
	InMemory bool
}

func DefaultStableStoreConfig

func DefaultStableStoreConfig(path string) *StableStoreConfig

func (*StableStoreConfig) WithInMemory

func (c *StableStoreConfig) WithInMemory(inMemory bool) *StableStoreConfig

func (*StableStoreConfig) WithPath

func (c *StableStoreConfig) WithPath(path string) *StableStoreConfig

func (*StableStoreConfig) WithSync

func (c *StableStoreConfig) WithSync(sync bool) *StableStoreConfig

Jump to

Keyboard shortcuts

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