nchash

package module
v0.0.0-...-7556a21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2015 License: Apache-2.0 Imports: 5 Imported by: 0

README

nchash

Nginx consistent hash golang version
If you are using nginx consistent hash in upstream, this would give you the same result as nginx consistent hash

Using

Importing ::

import "github.com/bydsky/nchash"

Basic example usage ::

nodes := []string{"192.168.0.1:8888",
                  "192.168.0.2:8888",
                  "192.168.0.3:8888"}

nc := nchash.New(nodes)
server := nc.Get("test")

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Update

func Update(crc uint32, p []byte) uint32

Types

type Chash

type Chash struct {
	// contains filtered or unexported fields
}

func New

func New(nodes []string) *Chash

func NewWithWeights

func NewWithWeights(nodeMap map[string]int, vnodeNum int) *Chash

func (*Chash) Get

func (h *Chash) Get(key string) (node string, err error)

type NginxCrc

type NginxCrc struct {
	// contains filtered or unexported fields
}

func NewNiginxCrc

func NewNiginxCrc() *NginxCrc

func (*NginxCrc) BlockSize

func (n *NginxCrc) BlockSize() int

func (*NginxCrc) Reset

func (n *NginxCrc) Reset()

func (*NginxCrc) Size

func (n *NginxCrc) Size() int

func (*NginxCrc) Sum

func (n *NginxCrc) Sum(in []byte) []byte

func (*NginxCrc) Sum32

func (n *NginxCrc) Sum32() uint32

func (*NginxCrc) Write

func (n *NginxCrc) Write(p []byte) (length int, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL