MCPcopy
hub / github.com/grafana/dskit / NewRingsServiceDiscovery

Function NewRingsServiceDiscovery

ring/client/ring_service_discovery.go:29–56  ·  view source on GitHub ↗

NewRingsServiceDiscovery returns a PoolServiceDiscovery listing the deduplicated addresses of all healthy instances across the given rings.

(rings []ring.ReadRing)

Source from the content-addressed store, hash-verified

27// NewRingsServiceDiscovery returns a PoolServiceDiscovery listing the deduplicated addresses
28// of all healthy instances across the given rings.
29func NewRingsServiceDiscovery(rings []ring.ReadRing) PoolServiceDiscovery {
30 discoveries := make([]PoolServiceDiscovery, len(rings))
31 for i, r := range rings {
32 discoveries[i] = NewRingServiceDiscovery(r)
33 }
34
35 return func() ([]string, error) {
36 var addrs []string
37 seen := map[string]struct{}{}
38
39 for _, discovery := range discoveries {
40 ringAddrs, err := discovery()
41 if err != nil {
42 return nil, err
43 }
44
45 for _, addr := range ringAddrs {
46 if _, ok := seen[addr]; ok {
47 continue
48 }
49 seen[addr] = struct{}{}
50 addrs = append(addrs, addr)
51 }
52 }
53
54 return addrs, nil
55 }
56}

Callers 1

Calls 1

NewRingServiceDiscoveryFunction · 0.85

Tested by 1