Documentation ¶
Index ¶
- Variables
- func DefaultHasher(id string) uint32
- func FindInGOPATH(filename string) string
- func ServeRing(r *Ring, addr string)
- func ServeRingManager(rm *RingManager, addr string)
- type Ring
- type RingManager
- func (rm *RingManager) AddKey(key string) error
- func (rm *RingManager) AddNode(nodeID string) error
- func (rm *RingManager) GetKeys(nodeID string) (nodes, error)
- func (rm *RingManager) GetNodes() []string
- func (rm *RingManager) RemoveKey(key string) error
- func (rm *RingManager) RemoveNode(nodeID string) error
- func (rm *RingManager) SetKeyFetcher(fn func(nodeRing, dataRing *Ring, id string) (nodes, error))
- func (rm *RingManager) SetKeyStorer(fn func(key string) error)
Constants ¶
This section is empty.
Variables ¶
var Debug = false
Debug if true, prints verbose logging
var ErrNotFound = errors.New("node not found")
Functions ¶
func FindInGOPATH ¶
FindInGOPATH searches through all GOPATHS and attempts to find the given file this is useful here because we want to find chring files but we can't know the relative import path as the importer could be a subpackage
func ServeRingManager ¶
func ServeRingManager(rm *RingManager, addr string)
ServeRingManager presents a web view into your consistent hash ring manager
Types ¶
type Ring ¶
Ring is a consistent hash ring. Use New() to create a ring. You may change out the hasher function to change key balancing if needed.
func NewRing ¶
func NewRing() *Ring
New creates a new consistent hash ring with a default hashing algo
type RingManager ¶
func NewRingManager ¶
func NewRingManager() *RingManager
func (*RingManager) AddKey ¶
func (rm *RingManager) AddKey(key string) error
func (*RingManager) AddNode ¶
func (rm *RingManager) AddNode(nodeID string) error
func (*RingManager) GetKeys ¶
func (rm *RingManager) GetKeys(nodeID string) (nodes, error)
func (*RingManager) GetNodes ¶
func (rm *RingManager) GetNodes() []string
func (*RingManager) RemoveKey ¶
func (rm *RingManager) RemoveKey(key string) error
func (*RingManager) RemoveNode ¶
func (rm *RingManager) RemoveNode(nodeID string) error
func (*RingManager) SetKeyFetcher ¶
func (rm *RingManager) SetKeyFetcher(fn func(nodeRing, dataRing *Ring, id string) (nodes, error))
SetKeyFetcher allows a user to override the default in memory ring store
func (*RingManager) SetKeyStorer ¶
func (rm *RingManager) SetKeyStorer(fn func(key string) error)
SetKeyStorer allows a user to override the default in memory key store