MCPcopy
hub / github.com/grafana/tempo / PickServer

Method PickServer

pkg/cache/memcached_client_selector.go:105–116  ·  view source on GitHub ↗

PickServer returns the server address that a given item should be shared onto.

(key string)

Source from the content-addressed store, hash-verified

103// PickServer returns the server address that a given item
104// should be shared onto.
105func (s *MemcachedJumpHashSelector) PickServer(key string) (net.Addr, error) {
106 s.mu.RLock()
107 defer s.mu.RUnlock()
108 if len(s.addrs) == 0 {
109 return nil, memcache.ErrNoServers
110 } else if len(s.addrs) == 1 {
111 return s.addrs[0], nil
112 }
113 cs := xxhash.Sum64String(key)
114 idx := jumpHash(cs, len(s.addrs))
115 return s.addrs[idx], nil
116}
117
118// Each iterates over each server and calls the given function.
119// If f returns a non-nil error, iteration will stop and that

Calls 1

jumpHashFunction · 0.85