Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Repository files navigation

node

Achieve this repo, move it into github.com/iTellis/common

a nodes ring for a key to get node

Build

  • GoDoc

Get Node Methods

Direct

dierct to get last added node, node's wight is unavailable

Consistent hashing

WIKI

Random

to get the node by random

Usage

// 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
}

New a node manager

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

Releases

Packages

Used by

Contributors

Languages