25
)
26
27
>
func NewClockedRateLimiter(rateLimiter *rate.Limiter, timeSource clock.TimeSource) ClockedRateLimiter {
clocked_rate_limiter.go
28
>
return ClockedRateLimiter{
29
>
rateLimiter: rateLimiter,
30
>
timeSource: timeSource,
31
>
recycleCh: make(chan struct{}),
32
>
}
33
>
}
34
36
>
return l.AllowN(l.timeSource.Now(), 1)
37
>
}
38
40
>
return l.rateLimiter.AllowN(now, token)
41
>
}
42
43
// ClockedReservation wraps a rate.Reservation with a clockwork.Clock. It is used to ensure that the reservation