Documentation ¶
Index ¶
- Constants
- Variables
- func RedirectKeyRequest(rs *raft.Raft, cmd, k, v string, exp int64) error
- func RedirectRaftRequest(rs *raft.Raft, nodeId, addr string) error
- type BadgerStore
- func (b *BadgerStore) Close() error
- func (b *BadgerStore) DeleteRange(min, max uint64) error
- func (b *BadgerStore) FirstIndex() (uint64, error)
- func (b *BadgerStore) Get(key []byte) ([]byte, error)
- func (b *BadgerStore) GetLog(index uint64, log *raft.Log) error
- func (b *BadgerStore) GetUint64(key []byte) (uint64, error)
- func (b *BadgerStore) LastIndex() (uint64, error)
- func (b *BadgerStore) Set(key []byte, val []byte) error
- func (b *BadgerStore) SetUint64(key []byte, val uint64) error
- func (b *BadgerStore) StoreLog(log *raft.Log) error
- func (b *BadgerStore) StoreLogs(logs []*raft.Log) error
- type ClusterState
- type CustomLogger
- func (c *CustomLogger) Debug(msg string, args ...interface{})
- func (c *CustomLogger) Error(msg string, args ...interface{})
- func (c *CustomLogger) GetLevel() hclog.Level
- func (c *CustomLogger) ImpliedArgs() []interface{}
- func (c *CustomLogger) Info(msg string, args ...interface{})
- func (c *CustomLogger) IsDebug() bool
- func (c *CustomLogger) IsError() bool
- func (c *CustomLogger) IsInfo() bool
- func (c *CustomLogger) IsTrace() bool
- func (c *CustomLogger) IsWarn() bool
- func (c *CustomLogger) Log(level hclog.Level, msg string, args ...interface{})
- func (c *CustomLogger) Name() string
- func (c *CustomLogger) Named(name string) hclog.Logger
- func (c *CustomLogger) ResetNamed(name string) hclog.Logger
- func (c *CustomLogger) SetLevel(level hclog.Level)
- func (c *CustomLogger) StandardLogger(opts *hclog.StandardLoggerOptions) *log.Logger
- func (c *CustomLogger) StandardWriter(opts *hclog.StandardLoggerOptions) io.Writer
- func (c *CustomLogger) Trace(msg string, args ...interface{})
- func (c *CustomLogger) Warn(msg string, args ...interface{})
- func (c *CustomLogger) With(args ...interface{}) hclog.Logger
- type Options
- type PeerState
- type Store
- func (s *Store) Delete(key string) error
- func (s *Store) Get(key string) (string, error)
- func (s *Store) Join(nodeID, addr string) error
- func (s *Store) Open(enableSingle bool, localID string) error
- func (s *Store) Raft() *raft.Raft
- func (s *Store) Remove(nodeId, addr string) error
- func (s *Store) ScanKeys(p string) []string
- func (s *Store) ScanKvs(p string) map[string]string
- func (s *Store) Set(key, value string, exp int64) error
Constants ¶
const ( CmdSet = "set" CmdSetEx = "setex" CmdDel = "del" )
Variables ¶
var ( // ErrKeyNotFound is an error indicating a given key does not exist ErrKeyNotFound = errors.New("not found") )
Functions ¶
func RedirectKeyRequest ¶
RedirectKeyRequest redirect the request to leader node
Types ¶
type BadgerStore ¶
type BadgerStore struct {
// contains filtered or unexported fields
}
func (*BadgerStore) Close ¶
func (b *BadgerStore) Close() error
Close is used to gracefully close the DB connection.
func (*BadgerStore) DeleteRange ¶
func (b *BadgerStore) DeleteRange(min, max uint64) error
DeleteRange deletes logs within a given range inclusively.
func (*BadgerStore) FirstIndex ¶
func (b *BadgerStore) FirstIndex() (uint64, error)
FirstIndex returns the first known index from the Raft log.
func (*BadgerStore) Get ¶
func (b *BadgerStore) Get(key []byte) ([]byte, error)
Get is used to retrieve a value from the k/v store by key
func (*BadgerStore) GetLog ¶
func (b *BadgerStore) GetLog(index uint64, log *raft.Log) error
GetLog gets a log entry from Badger at a given index.
func (*BadgerStore) GetUint64 ¶
func (b *BadgerStore) GetUint64(key []byte) (uint64, error)
GetUint64 is like Get, but handles uint64 values
func (*BadgerStore) LastIndex ¶
func (b *BadgerStore) LastIndex() (uint64, error)
LastIndex returns the last known index from the Raft log.
func (*BadgerStore) Set ¶
func (b *BadgerStore) Set(key []byte, val []byte) error
Set is used to set a key/value set outside the raft log.
func (*BadgerStore) SetUint64 ¶
func (b *BadgerStore) SetUint64(key []byte, val uint64) error
SetUint64 is like Set, but handles uint64 values
type ClusterState ¶
type ClusterState struct { LeaderId string `json:"leaderId,omitempty"` LeaderAddr string `json:"leaderAddr,omitempty"` Peers []PeerState `json:"peers,omitempty"` }
func NewClusterInfo ¶
func NewClusterInfo(rs *raft.Raft) *ClusterState
func (*ClusterState) String ¶
func (c *ClusterState) String() string
type CustomLogger ¶
type CustomLogger struct {
// contains filtered or unexported fields
}
func NewCustomLogger ¶
func NewCustomLogger(l *logrus.Logger, name string) *CustomLogger
func (*CustomLogger) Debug ¶
func (c *CustomLogger) Debug(msg string, args ...interface{})
func (*CustomLogger) Error ¶
func (c *CustomLogger) Error(msg string, args ...interface{})
func (*CustomLogger) GetLevel ¶
func (c *CustomLogger) GetLevel() hclog.Level
func (*CustomLogger) ImpliedArgs ¶
func (c *CustomLogger) ImpliedArgs() []interface{}
func (*CustomLogger) Info ¶
func (c *CustomLogger) Info(msg string, args ...interface{})
func (*CustomLogger) IsDebug ¶
func (c *CustomLogger) IsDebug() bool
func (*CustomLogger) IsError ¶
func (c *CustomLogger) IsError() bool
func (*CustomLogger) IsInfo ¶
func (c *CustomLogger) IsInfo() bool
func (*CustomLogger) IsTrace ¶
func (c *CustomLogger) IsTrace() bool
func (*CustomLogger) IsWarn ¶
func (c *CustomLogger) IsWarn() bool
func (*CustomLogger) Log ¶
func (c *CustomLogger) Log(level hclog.Level, msg string, args ...interface{})
func (*CustomLogger) Name ¶
func (c *CustomLogger) Name() string
func (*CustomLogger) Named ¶
func (c *CustomLogger) Named(name string) hclog.Logger
func (*CustomLogger) ResetNamed ¶
func (c *CustomLogger) ResetNamed(name string) hclog.Logger
func (*CustomLogger) SetLevel ¶
func (c *CustomLogger) SetLevel(level hclog.Level)
func (*CustomLogger) StandardLogger ¶
func (c *CustomLogger) StandardLogger(opts *hclog.StandardLoggerOptions) *log.Logger
func (*CustomLogger) StandardWriter ¶
func (c *CustomLogger) StandardWriter(opts *hclog.StandardLoggerOptions) io.Writer
func (*CustomLogger) Trace ¶
func (c *CustomLogger) Trace(msg string, args ...interface{})
func (*CustomLogger) Warn ¶
func (c *CustomLogger) Warn(msg string, args ...interface{})
func (*CustomLogger) With ¶
func (c *CustomLogger) With(args ...interface{}) hclog.Logger
type Options ¶
type Options struct { // Path is the directory path to the Badger db to use. Path string // BadgerOptions contains any specific Badger options you might // want to specify. BadgerOptions *badger.Options // NoSync causes the database to skip fsync calls after each // write to the log. This is unsafe, so it should be used // with caution. NoSync bool }
Options contains all the configuration used to open the Badger db
type Store ¶
type Store struct { DataDir string RaftDir string RaftBindAddr string // contains filtered or unexported fields }
func (*Store) Join ¶
Join joins a node, identified by nodeID and located at addr, to this store. The node must be ready to respond to Raft communications at that address.
func (*Store) Open ¶
Open opens the store. If enableSingle is set, and there are no existing peers, then this node becomes the first node, and therefore leader, of the cluster. localID should be the server identifier for this node.