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

Function shouldIncludeReadonlyInstanceInTheShard

ring/ring.go:1124–1138  ·  view source on GitHub ↗

shouldIncludeReadonlyInstanceInTheShard returns true if instance is not read-only, or when it is read-only and should be included in the shuffle shard.

(instance InstanceDesc, lookbackPeriod time.Duration, lookbackUntil int64)

Source from the content-addressed store, hash-verified

1122
1123// shouldIncludeReadonlyInstanceInTheShard returns true if instance is not read-only, or when it is read-only and should be included in the shuffle shard.
1124func shouldIncludeReadonlyInstanceInTheShard(instance InstanceDesc, lookbackPeriod time.Duration, lookbackUntil int64) bool {
1125 if !instance.ReadOnly {
1126 return true
1127 }
1128 // The lookbackPeriod is 0 when this function is called by ShuffleShard(). In this case, we want read only instances excluded.
1129 if lookbackPeriod == 0 {
1130 return false
1131 }
1132 // With lookback period >0, read only instances are only included if they have not changed read-only status in the lookback window.
1133 // If ReadOnlyUpdatedTimestamp is not set, we include the instance, and extend the shard later.
1134 if lookbackPeriod > 0 && instance.ReadOnlyUpdatedTimestamp > 0 && instance.ReadOnlyUpdatedTimestamp < lookbackUntil {
1135 return false
1136 }
1137 return true
1138}
1139
1140// filterOutReadOnlyInstances removes all read-only instances from the ring, and returns the resulting ring.
1141func (r *Ring) filterOutReadOnlyInstances(lookbackPeriod time.Duration, now time.Time) *Ring {

Callers 2

shuffleShardMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected