Documentation ¶
Index ¶
- type ConsistentHash
- func (c *ConsistentHash) Add(ep endpoint.Endpoint) error
- func (c *ConsistentHash) Find(key string) (endpoint.Endpoint, bool)
- func (c *ConsistentHash) FindInt32(key uint32) (endpoint.Endpoint, bool)
- func (c *ConsistentHash) Refresh(eps []endpoint.Endpoint)
- func (c *ConsistentHash) Remove(ep endpoint.Endpoint) error
- func (c *ConsistentHash) Select(msg selector.Message) (ep endpoint.Endpoint, err error)
- type DefaultHashAlg
- type HashAlgorithmType
- type KetamaHashAlg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConsistentHash ¶
ConsistentHash consistent hash map
func New ¶
func New(enableWeight bool, hashType HashAlgorithmType) *ConsistentHash
New create a ConsistentHash which has replicates of virtual endpoint.Endpoint.
func (*ConsistentHash) Add ¶
func (c *ConsistentHash) Add(ep endpoint.Endpoint) error
Add the ep to the hash ring
func (*ConsistentHash) Find ¶
func (c *ConsistentHash) Find(key string) (endpoint.Endpoint, bool)
Find finds a endpoint.Endpoint to put the string key
func (*ConsistentHash) FindInt32 ¶
func (c *ConsistentHash) FindInt32(key uint32) (endpoint.Endpoint, bool)
FindInt32 finds a endpoint.Endpoint to put the uint32 key
func (*ConsistentHash) Refresh ¶
func (c *ConsistentHash) Refresh(eps []endpoint.Endpoint)
func (*ConsistentHash) Remove ¶
func (c *ConsistentHash) Remove(ep endpoint.Endpoint) error
Remove the ep and all the virtual eps from the key
type DefaultHashAlg ¶
type DefaultHashAlg struct { }
func (DefaultHashAlg) GetHashType ¶
func (k DefaultHashAlg) GetHashType() HashAlgorithmType
func (DefaultHashAlg) Hash ¶
func (k DefaultHashAlg) Hash(key string) uint32
type HashAlgorithmType ¶
type HashAlgorithmType int
const ( KetamaHash HashAlgorithmType = 0 DefaultHash HashAlgorithmType = 1 )
type KetamaHashAlg ¶
type KetamaHashAlg struct { }
func (KetamaHashAlg) GetHashType ¶
func (k KetamaHashAlg) GetHashType() HashAlgorithmType
func (KetamaHashAlg) Hash ¶
func (k KetamaHashAlg) Hash(key string) uint32
Click to show internal directories.
Click to hide internal directories.