Achieve this repo, move it into github.com/iTellis/common
a nodes ring for a key to get node
dierct to get last added node, node's wight is unavailable
to get the node by random
// Node params for a nodetypeNodestruct {
// for recognize node with input idIDstring// node's probability weightWeightuint32// node's valueValuestring// kvs for meta dataMetadata config.Optionsnumberuint32
}
// Manager node manager functions defines.typeManagerinterface {
// adds a node to the node ring.Add(node*Node)
// get the node responsible for the data key.NodeFor(keys...string) (*Node, bool)
// removes all nodes from the node ring.Remove()
// removes a node from the node ring.RemoveByID(idstring)
// print all nodesPrintNodes()
// is the node ring emptyIsEmpty() bool
}directNode, _:=node.New(node.NodeTypeDirect, "direct")
randomNode, _:=node.New(node.NodeTypeRandom, "random")
consistentNode, _:=node.New(node.NodeTypeConsistent, "consistent")
roundrobinNode, _:=node.New(node.NodeTypeRoundRobin, "roundrobin")Or
directNode, _:=node.NewDirect("direct")
randomNode, _:=node.NewRandom("random")
consistentNode, _:=node.NewConsistent("consistent")
roundrobinNode, _:=node.NewRoundRobin("roundrobin")