@@ -50,15 +50,15 @@ func (l *TimeLimiter) add(now time.Time, d time.Duration) {
5050}
5151
5252// Wait returns when we are not rate limited
53- // * if we passed the window, we reset everything (this is only safe for callers
53+ // - if we passed the window, we reset everything (this is only safe for callers
5454// that behave correctly, i.e. that wait the instructed time after each add)
55- // * if limit is not reached, no sleep is needed
56- // * if limit has been exceeded, sleep until next period + extra multiple to compensate
57- // this is perhaps best explained with an example:
58- // if window is 1s and limit 100ms, but we spent 250ms, then we spent effectively 2.5 seconds worth of work.
59- // let's say we are 800ms into the 1s window, that means we should sleep 2500-800 = 1.7s
60- // in order to maximize work while honoring the imposed limit.
61- // * if limit has been met exactly, sleep until next period (this is a special case of the above)
55+ // - if limit is not reached, no sleep is needed
56+ // - if limit has been exceeded, sleep until next period + extra multiple to compensate
57+ // this is perhaps best explained with an example:
58+ // if window is 1s and limit 100ms, but we spent 250ms, then we spent effectively 2.5 seconds worth of work.
59+ // let's say we are 800ms into the 1s window, that means we should sleep 2500-800 = 1.7s
60+ // in order to maximize work while honoring the imposed limit.
61+ // - if limit has been met exactly, sleep until next period (this is a special case of the above)
6262func (l * TimeLimiter ) Wait () {
6363 time .Sleep (l .wait (time .Now ()))
6464}
0 commit comments