Skip to content

Commit

Permalink
feat: expose lookback time for recalculation
Browse files Browse the repository at this point in the history
  • Loading branch information
turip committed Aug 9, 2024
1 parent 09a4c82 commit 79ef225
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/entitlement/balanceworker/recalculate.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import (
)

const (
// defaultIncludeDeletedDuration is the default duration for which deleted entitlements are included in recalculation.
// DefaultIncludeDeletedDuration is the default duration for which deleted entitlements are included in recalculation.
// This ensures that the recent deleted snapshot events are also resent.
defaultIncludeDeletedDuration = 24 * time.Hour
DefaultIncludeDeletedDuration = 24 * time.Hour

defaultLRUCacheSize = 10_000
)
Expand Down Expand Up @@ -66,7 +66,7 @@ func (r *Recalculator) Recalculate(ctx context.Context) error {
entitlement.ListEntitlementsParams{
Namespaces: []string{r.opts.Namespace},
IncludeDeleted: true,
IncludeDeletedAfter: time.Now().Add(-defaultIncludeDeletedDuration),
IncludeDeletedAfter: time.Now().Add(-DefaultIncludeDeletedDuration),
})
if err != nil {
return err
Expand Down
4 changes: 4 additions & 0 deletions openmeter/entitlement/balanceworker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ type (
RecalculatorOptions = balanceworker.RecalculatorOptions
)

const (
DefaultIncludeDeletedDuration = balanceworker.DefaultIncludeDeletedDuration
)

func NewRecalculator(opts RecalculatorOptions) (*Recalculator, error) {
return balanceworker.NewRecalculator(opts)
}

0 comments on commit 79ef225

Please sign in to comment.