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

Method GetTokens

ring/model.go:495–508  ·  view source on GitHub ↗

GetTokens returns sorted list of tokens owned by all instances within the ring.

()

Source from the content-addressed store, hash-verified

493
494// GetTokens returns sorted list of tokens owned by all instances within the ring.
495func (d *Desc) GetTokens() []uint32 {
496 instances := make([][]uint32, 0, len(d.Ingesters))
497 for _, instance := range d.Ingesters {
498 // Tokens may not be sorted for an older version which, so we enforce sorting here.
499 tokens := instance.Tokens
500 if !sort.IsSorted(Tokens(tokens)) {
501 sort.Sort(Tokens(tokens))
502 }
503
504 instances = append(instances, tokens)
505 }
506
507 return MergeTokens(instances)
508}
509
510// getTokensByZone returns instances tokens grouped by zone. Tokens within each zone
511// are guaranteed to be sorted.

Calls 2

TokensTypeAlias · 0.85
MergeTokensFunction · 0.85