Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make public the syncronisation between redis and the source of truth for a limit #89

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion redis/count_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ func (cr *CountResource) Available(ctx context.Context, tenantID string) (int64,
}

// count is now zero so check the actual number of resources and adjust if necessary.
newLimit, err := cr.refreshLimit(ctx, tenantID)
newLimit, err := cr.RefreshLimit(ctx, tenantID)
if err != nil {
log.Infof("reset count failure: %v", err)
newLimit = limit
Expand Down
6 changes: 3 additions & 3 deletions redis/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,11 @@ func (r *Resource) getLimit(ctx context.Context, tenantID string) (int64, error)
return limit, nil
}
// we haven't got the redis limit therefore attempt to retrieve from upstream
return r.refreshLimit(ctx, tenantID)
return r.RefreshLimit(ctx, tenantID)
}

// refreshLimit gets the limit for a given tenant from upstream.
func (r *Resource) refreshLimit(ctx context.Context, tenantID string) (int64, error) {
// RefreshLimit gets the limit for a given tenant from upstream.
func (r *Resource) RefreshLimit(ctx context.Context, tenantID string) (int64, error) {
log := r.Log().FromContext(ctx)
defer log.Close()

Expand Down
Loading