store

package
v0.0.0-...-3f8bf2f Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CmdSet    = "SET"
	CmdDelete = "DELETE"
)

Variables

View Source
var (
	ErrKeyNotFound = errors.New("not found")
	ErrCorrupt     = errors.New("corrupt")
)

Functions

This section is empty.

Types

type BoltStore

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

BoltStore wraps boltdb and implements the interfaces raft.LogStore to store raft logs and raft.StableStore for key/value storage. The interfaces are defined in hashicorp/raft library

func New

func New(options Options) (*BoltStore, error)

func NewBoltStore

func NewBoltStore(path string) (*BoltStore, error)

func (*BoltStore) Close

func (b *BoltStore) Close() error

Close the BoltStore db

func (*BoltStore) DeleteRange

func (b *BoltStore) DeleteRange(min, max uint64) error

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

func (*BoltStore) FirstIndex

func (b *BoltStore) FirstIndex() (uint64, error)

FirstIndex returns the first index of raft logs written. 0 for no entries.

func (*BoltStore) Get

func (b *BoltStore) Get(k []byte) ([]byte, error)

func (*BoltStore) GetLog

func (b *BoltStore) GetLog(idx uint64, log *raft.Log) error

GetLog gets a log entry at a given index.

func (*BoltStore) GetUint64

func (b *BoltStore) GetUint64(key []byte) (uint64, error)

func (*BoltStore) LastIndex

func (b *BoltStore) LastIndex() (uint64, error)

LastIndex returns the last index of raft logs written. 0 for no entries.

func (*BoltStore) Set

func (b *BoltStore) Set(k, v []byte) error

func (*BoltStore) SetUint64

func (b *BoltStore) SetUint64(key []byte, val uint64) error

func (*BoltStore) StoreLog

func (b *BoltStore) StoreLog(log *raft.Log) error

StoreLog stores a log entry.

func (*BoltStore) StoreLogs

func (b *BoltStore) StoreLogs(logs []*raft.Log) error

StoreLogs stores multiple log entries.

func (*BoltStore) Sync

func (b *BoltStore) Sync() error

Sync executes fdatasync() against the database file handle.

This is not necessary under normal operation, however, if you use NoSync then it allows you to force the database file to sync against the disk.

type Node

type Node struct {
	NodeID   string
	RaftAddr string
}

type Options

type Options struct {
	// Path is the file path to the boltDB to use
	Path string

	BoltOptions *bbolt.Options

	// NoSync causes the database to skip fsync calls after each
	// write to the log.
	NoSync bool
}

type Store

type Store struct {
	RaftDir  string
	RaftAddr string
	// contains filtered or unexported fields
}

func NewStore

func NewStore() *Store

func (*Store) AddNode

func (s *Store) AddNode(nodeID, addr string) error

AddNode adds a new Node to raft cluster. This should be called from the leader Node

func (*Store) DataDir

func (s *Store) DataDir(raftAddr string) string

func (*Store) Delete

func (s *Store) Delete(key string) error

func (*Store) Get

func (s *Store) Get(key string) string

func (*Store) Keys

func (s *Store) Keys() []string

func (*Store) Leader

func (s *Store) Leader() Node

func (*Store) NodeList

func (s *Store) NodeList() ([]Node, error)

func (*Store) Open

func (s *Store) Open(bootstrapCluster bool, localID string) error

func (*Store) Set

func (s *Store) Set(key string, value string) error

func (*Store) Snapshot

func (s *Store) Snapshot() error

Jump to

Keyboard shortcuts

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