Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code review changes
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.com>
56quarters committed Jan 28, 2025

Verified

This commit was signed with the committer’s verified signature.
woodruffw William Woodruff
1 parent 2541b9b commit 32f88af
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pkg/storegateway/dynamic_replication.go
Original file line number Diff line number Diff line change
@@ -67,9 +67,9 @@ func (n NopDynamicReplication) EligibleForQuerying(ReplicatedBlock) bool {

func NewMaxTimeDynamicReplication(maxTime time.Duration, gracePeriod time.Duration) *MaxTimeDynamicReplication {
return &MaxTimeDynamicReplication{
maxTime: maxTime,
gracePeriod: gracePeriod,
now: time.Now,
maxTimeThreshold: maxTime,
gracePeriod: gracePeriod,
now: time.Now,
}
}

@@ -78,9 +78,9 @@ func NewMaxTimeDynamicReplication(maxTime time.Duration, gracePeriod time.Durati
// recent sample) is. A grace period can optionally be used to ensure that blocks are
// synced to store-gateways until they are no longer being queried.
type MaxTimeDynamicReplication struct {
maxTime time.Duration
gracePeriod time.Duration
now func() time.Time
maxTimeThreshold time.Duration
gracePeriod time.Duration
now func() time.Time
}

func (e *MaxTimeDynamicReplication) EligibleForSync(b ReplicatedBlock) bool {
@@ -89,11 +89,11 @@ func (e *MaxTimeDynamicReplication) EligibleForSync(b ReplicatedBlock) bool {
// We keep syncing blocks for `gracePeriod` after they are no longer eligible for
// querying to ensure that they are not unloaded by store-gateways while still being
// queried.
return maxTimeDelta <= (e.maxTime + e.gracePeriod)
return maxTimeDelta <= (e.maxTimeThreshold + e.gracePeriod)
}

func (e *MaxTimeDynamicReplication) EligibleForQuerying(b ReplicatedBlock) bool {
now := e.now()
maxTimeDelta := now.Sub(b.GetMaxTime())
return maxTimeDelta <= e.maxTime
return maxTimeDelta <= e.maxTimeThreshold
}

0 comments on commit 32f88af

Please sign in to comment.