Skip to content

Commit

Permalink
Revert accidental removal.
Browse files Browse the repository at this point in the history
  • Loading branch information
beautifulentropy committed Oct 25, 2023
1 parent 76a020a commit 3ce9716
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ratelimits/limiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ func (l *Limiter) Check(ctx context.Context, bucket BucketWithCost) (*Decision,
return nil, err
}

if bucket.cost > limit.Burst {
return nil, ErrInvalidCostOverLimit
}

// Remove cancellation from the request context so that transactions are not
// interrupted by a client disconnect.
ctx = context.WithoutCancel(ctx)
Expand Down Expand Up @@ -171,6 +175,10 @@ func (l *Limiter) Spend(ctx context.Context, bucket BucketWithCost) (*Decision,
return nil, err
}

if bucket.cost > limit.Burst {
return nil, ErrInvalidCostOverLimit
}

start := l.clk.Now()
status := Denied
defer func() {
Expand Down

0 comments on commit 3ce9716

Please sign in to comment.