dkvdb

package module
v0.0.0-...-69c2e64 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: MIT Imports: 19 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

DKVDB

A simple distributed Key-Value database using raft consensus protocol.

Constraint.

Reads have Serializability Semantics on followers.

Documentation

Index

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) Shutdown

func (ns *NodeStorage) Shutdown()

Shutdown this raft node.

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

type RedisKV struct {
	MUX *redcon.ServeMux
	// contains filtered or unexported fields
}

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) Delete

func (rr *RedisKV) Delete(conn redcon.Conn, cmd redcon.Command)

Delete the key from redis conn from the database.

func (*RedisKV) Get

func (rr *RedisKV) Get(conn redcon.Conn, cmd redcon.Command)

Get returns the value if any for the given key to redis conn

func (*RedisKV) JoinCluster

func (rr *RedisKV) JoinCluster(conn redcon.Conn, cmd redcon.Command)

JoinCluster add's the given cluster to the leader

func (*RedisKV) Ping

func (rr *RedisKV) Ping(conn redcon.Conn, cmd redcon.Command)

Ping responds to ping redis protocol

func (*RedisKV) Quit

func (rr *RedisKV) Quit(conn redcon.Conn, cmd redcon.Command)

Quit closes the corrent TCP redis onn

func (*RedisKV) Set

func (rr *RedisKV) Set(conn redcon.Conn, cmd redcon.Command)

Set the key value from redis conn to the database

Directories

Path Synopsis
cmd
raftredis command
internal
proto

Jump to

Keyboard shortcuts

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