Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Shuning Chen <[email protected]>
  • Loading branch information
Shuning Chen authored and Shuning Chen committed Jul 3, 2024
1 parent dcebb36 commit 834e620
Showing 1 changed file with 11 additions and 20 deletions.
31 changes: 11 additions & 20 deletions client/resource_group/controller/limiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,19 +141,14 @@ func NewLimiterWithCfg(name string, now time.Time, cfg tokenBucketReconfigureArg
// A Reservation holds information about events that are permitted by a Limiter to happen after a delay.
// A Reservation may be canceled, which may enable the Limiter to permit additional events.
type Reservation struct {
ok bool
lim *Limiter
tokens float64
timeToAct time.Time
needWaitDurtion time.Duration
ok bool
lim *Limiter
tokens float64
timeToAct time.Time
needWaitDuration time.Duration
// This is the Limit at reservation time, it can change later.
<<<<<<< HEAD
limit Limit
=======
limit Limit
remainingTokens float64
err error
>>>>>>> 49f9b115c (client/controller: record context error and add slowlog about token bucket (#8344))
err error
}

// OK returns whether the limiter can provide the requested number of tokens
Expand Down Expand Up @@ -398,10 +393,10 @@ func (lim *Limiter) reserveN(now time.Time, n float64, maxFutureReserve time.Dur

// Prepare reservation
r := Reservation{
ok: ok,
lim: lim,
limit: lim.limit,
needWaitDurtion: waitDuration,
ok: ok,
lim: lim,
limit: lim.limit,
needWaitDuration: waitDuration,
}
if ok {
r.tokens = n
Expand Down Expand Up @@ -506,14 +501,10 @@ func WaitReservations(ctx context.Context, now time.Time, reservations []*Reserv
for _, res := range reservations {
if !res.ok {
cancel()
<<<<<<< HEAD
return res.needWaitDurtion, errs.ErrClientResourceGroupThrottled
=======
if res.err != nil {
return res.needWaitDuration, res.err
}
return res.needWaitDuration, errs.ErrClientResourceGroupThrottled.FastGenByArgs(res.needWaitDuration, res.limit, res.remainingTokens)
>>>>>>> 49f9b115c (client/controller: record context error and add slowlog about token bucket (#8344))
return res.needWaitDuration, errs.ErrClientResourceGroupThrottled
}
delay := res.DelayFrom(now)
if delay > longestDelayDuration {
Expand Down

0 comments on commit 834e620

Please sign in to comment.