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

Method ShuffleShardWithLookback

ring/ring.go:976–993  ·  view source on GitHub ↗

ShuffleShardWithLookback is like ShuffleShard() but the returned subring includes all instances that have been part of the identifier's shard since "now - lookbackPeriod". The returned subring may be unbalanced with regard to zones and should never be used for write operations (read only). This fu

(identifier string, size int, lookbackPeriod time.Duration, now time.Time)

Source from the content-addressed store, hash-verified

974// Subring returned by this method does not contain read-only instances that have changed their state
975// before the lookback period.
976func (r *Ring) ShuffleShardWithLookback(identifier string, size int, lookbackPeriod time.Duration, now time.Time) ReadRing {
977 if cached := r.getCachedShuffledSubringWithLookback(identifier, size, lookbackPeriod, now); cached != nil {
978 return cached
979 }
980
981 var result *Ring
982 if size <= 0 {
983 result = r.filterOutReadOnlyInstances(lookbackPeriod, now)
984 } else {
985 result = r.shuffleShard(identifier, size, lookbackPeriod, now)
986 }
987
988 if result != r {
989 r.setCachedShuffledSubringWithLookback(identifier, size, lookbackPeriod, now, result)
990 }
991
992 return result
993}
994
995func (r *Ring) shuffleShard(identifier string, size int, lookbackPeriod time.Duration, now time.Time) *Ring {
996 lookbackUntil := now.Add(-lookbackPeriod).Unix()

Callers

nothing calls this directly

Tested by

no test coverage detected