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

Function getRandomInstanceID

ring/ring_test.go:4564–4571  ·  view source on GitHub ↗

To make tests reproducible we sort the instance IDs in the map, and then get a random index via rnd.

(instances map[string]InstanceDesc, rnd *rand.Rand)

Source from the content-addressed store, hash-verified

4562
4563// To make tests reproducible we sort the instance IDs in the map, and then get a random index via rnd.
4564func getRandomInstanceID(instances map[string]InstanceDesc, rnd *rand.Rand) string {
4565 instanceIDs := make([]string, 0, len(instances))
4566 for id := range instances {
4567 instanceIDs = append(instanceIDs, id)
4568 }
4569 sort.Strings(instanceIDs)
4570 return instanceIDs[rnd.Intn(len(instanceIDs))]
4571}
4572
4573type mockError struct {
4574 isClientErr bool

Calls

no outgoing calls

Tested by

no test coverage detected