Documentation ¶
Index ¶
- Variables
- func MD5(key string) [16]byte
- type DB
- type Node
- type NodeManager
- func (nm *NodeManager) AddNode(index int, conf []string) (err error)
- func (nm *NodeManager) Del(key string) error
- func (nm *NodeManager) Get(key string) (string, error)
- func (nm *NodeManager) NewNode(conf string) (err error)
- func (nm *NodeManager) Set(key string, value string) error
- func (nm *NodeManager) String() string
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrConfFormat the format of configuration is wrong ErrConfFormat = errors.New("wrong conf format") // ErrConf bad configuration ErrConf = errors.New("wrong conf") // ErrNodeNotFound node not found ErrNodeNotFound = errors.New("node not found") // ErrNodeReplicate node replicate ErrNodeReplicate = errors.New("node replicate") // ErrNodeHasChildren node has children ErrNodeHasChildren = errors.New("node has children") // ErrKeyNotFound key not found ErrKeyNotFound = errors.New("key not found") )
View Source
var (
// RootIndex the index of root
RootIndex = 0
)
Functions ¶
Types ¶
type DB ¶
type DB interface { Set(key string, value string) error Get(key string) (string, error) Del(key string) error Close() error String() string }
DB is the interface of db, user must implement itself
type Node ¶
Node root's parent is itself
type NodeManager ¶
type NodeManager struct {
// contains filtered or unexported fields
}
NodeManager manage nodes
func NewNodeManager ¶
func NewNodeManager(f func(string) (DB, error)) (nm *NodeManager, err error)
NewNodeManager .
func (*NodeManager) AddNode ¶
func (nm *NodeManager) AddNode(index int, conf []string) (err error)
AddNode add the children of index node
func (*NodeManager) Get ¶
func (nm *NodeManager) Get(key string) (string, error)
Get find and return
func (*NodeManager) NewNode ¶
func (nm *NodeManager) NewNode(conf string) (err error)
NewNode build node tree
Click to show internal directories.
Click to hide internal directories.