Documentation
¶
Overview ¶
Package hashring implements a loadbalance.Selector that selects hosts using groupcache's consistenthash package.
Populate the correct request header before making the request because the value of the header is used as the key when choosing a host. Not setting the header will result in a malformed URL.
req, _ := http.NewRequest("GET", "http://host/foo/bar", nil) req.Header.Set(hashring.Header, "bar") client.Do(req)
See: https://godoc.org/github.com/golang/groupcache/consistenthash
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Header defines the HTTP header to use for the request's key. // The ring is searched using a hash of the key. Header = "HashRing-Key" // Hash is the default function used to hash hosts and keys. Hash = crc32.ChecksumIEEE // func([]byte) uint32 // Replicas defines the number of replica hosts created when // populating the ring. Replicas = 50 )
Functions ¶
func SelectFrom ¶
func SelectFrom(hosts ...string) loadbalance.Selector
SelectFrom returns a Selector that selects hosts using a hash ring.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.