Documentation ¶
Index ¶
- Constants
- func Hash(data []byte) uint64
- func HmacSha256(key, data []byte) []byte
- func Md5(data []byte) []byte
- func Md5HexBytes(data []byte) string
- func Md5HexString(data string) string
- func Sha1(data []byte) []byte
- func Sha1HexBytes(data []byte) string
- func Sha1HexString(data string) string
- func Sha256(data []byte) []byte
- type ConsistentHash
- type HashFunc
Constants ¶
View Source
const (
TopWeight = 100
)
Variables ¶
This section is empty.
Functions ¶
func Md5 ¶
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
func Md5HexBytes ¶
func Md5HexString ¶
func Sha1HexBytes ¶
func Sha1HexString ¶
Types ¶
type ConsistentHash ¶
type ConsistentHash struct {
// contains filtered or unexported fields
}
func NewConsistentHash ¶
func NewConsistentHash() *ConsistentHash
func NewCustomConsistentHash ¶
func NewCustomConsistentHash(replicas int, fn HashFunc) *ConsistentHash
func (*ConsistentHash) Add ¶
func (h *ConsistentHash) Add(node any)
Add adds the node with the number of h.replicas, the later call will overwrite the replicas of the former calls.
func (*ConsistentHash) AddWithReplicas ¶
func (h *ConsistentHash) AddWithReplicas(node any, replicas int)
AddWithReplicas adds the node with the number of replicas, replicas will be truncated to h.replicas if it's larger than h.replicas, the later call will overwrite the replicas of the former calls.
func (*ConsistentHash) AddWithWeight ¶
func (h *ConsistentHash) AddWithWeight(node any, weight int)
AddWithWeight adds the node with weight, the weight can be 1 to 100, indicates the percent, the later call will overwrite the replicas of the former calls.
func (*ConsistentHash) Remove ¶
func (h *ConsistentHash) Remove(node any)
Click to show internal directories.
Click to hide internal directories.