Documentation
¶
Index ¶
- func ApplyDefaultState(nc *config.RaftStorageConfig)
- func NewRaftTCPTransport(nc *config.RaftStorageConfig) (*raft.NetworkTransport, error)
- func ValidateRequired(nc *config.RaftStorageConfig) error
- type NodeStorage
- func (ns *NodeStorage) AddNewNode(nodeID, serverAddr string) error
- func (ns *NodeStorage) BootstrapThisNode() error
- func (ns *NodeStorage) Del(key []byte) error
- func (ns *NodeStorage) Get(key []byte) ([]byte, error)
- func (ns *NodeStorage) IsLeader() bool
- func (ns *NodeStorage) Set(key, val []byte) error
- func (ns *NodeStorage) Shutdown()
- func (ns *NodeStorage) StartRaft(ctx context.Context) error
- func (ns *NodeStorage) WithTransport(la raft.ServerAddress, rt raft.Transport)
- type RedisKV
- func (rr *RedisKV) Delete(conn redcon.Conn, cmd redcon.Command)
- func (rr *RedisKV) Get(conn redcon.Conn, cmd redcon.Command)
- func (rr *RedisKV) JoinCluster(conn redcon.Conn, cmd redcon.Command)
- func (rr *RedisKV) Ping(conn redcon.Conn, cmd redcon.Command)
- func (rr *RedisKV) Quit(conn redcon.Conn, cmd redcon.Command)
- func (rr *RedisKV) Set(conn redcon.Conn, cmd redcon.Command)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyDefaultState ¶
func ApplyDefaultState(nc *config.RaftStorageConfig)
ApplyDefaultState validates the given Config Parameter and Applies the sane default state if not present.
func NewRaftTCPTransport ¶
func NewRaftTCPTransport(nc *config.RaftStorageConfig) (*raft.NetworkTransport, error)
NewRaftTCPTransport returns a new initailzed raft TCP Network transport
func ValidateRequired ¶
func ValidateRequired(nc *config.RaftStorageConfig) error
ValidateRequired Checks if the given required Field has been set with proper value or not.
Types ¶
type NodeStorage ¶
type NodeStorage struct {
// contains filtered or unexported fields
}
NodeStorage defines individual node of a kv database.
func NewNodeStorage ¶
func NewNodeStorage(ctx context.Context, nc *config.RaftStorageConfig) (*NodeStorage, error)
NewNodeStorage returns an initialized Node Storage,
func (*NodeStorage) AddNewNode ¶
func (ns *NodeStorage) AddNewNode(nodeID, serverAddr string) error
AddNewNode handles joining cluster request
func (*NodeStorage) BootstrapThisNode ¶
func (ns *NodeStorage) BootstrapThisNode() error
BootstrapThisNode will try to bootsrap this server. Check for the state before Bootstraping A cluster can only be bootstrapped once from a single participating Voter server. Any further attempts to bootstrap will return an error that can be safely ignored.
func (*NodeStorage) Del ¶
func (ns *NodeStorage) Del(key []byte) error
Del tries to delete the provided key from the database.
func (*NodeStorage) Get ¶
func (ns *NodeStorage) Get(key []byte) ([]byte, error)
Get returns the value of the given key in local db. The values will be eventaully consistent. So it can be stale value.
func (*NodeStorage) IsLeader ¶
func (ns *NodeStorage) IsLeader() bool
IsLeader resports whether the given node is in leader state.
func (*NodeStorage) Set ¶
func (ns *NodeStorage) Set(key, val []byte) error
Set tries to store the given key value pair from the database.
func (*NodeStorage) StartRaft ¶
func (ns *NodeStorage) StartRaft(ctx context.Context) error
StartRaft is used to construct a new Raft node.
func (*NodeStorage) WithTransport ¶
func (ns *NodeStorage) WithTransport(la raft.ServerAddress, rt raft.Transport)
WithTransport attaches the supplied transport to raft cluster.
type RedisKV ¶
RedisKV wraps the provided distributed kv storage over redis protocol.
func NewRedisKVStorage ¶
func NewRedisKVStorage(ns *NodeStorage) (*RedisKV, error)
NewRedisKVStorage returns an initialized Redis Handler over the distributed Node storage.
func (*RedisKV) JoinCluster ¶
JoinCluster add's the given cluster to the leader