Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PaceLimiter ¶
type PaceLimiter struct {
// contains filtered or unexported fields
}
PaceLimiter throttles WaitIfNeeded callers while the number of Inc calls is bigger than the number of Dec calls.
It is expected that Inc is called before performing high-priority work, while Dec is called when the work is done. WaitIfNeeded must be called inside the work which must be throttled (i.e. lower-priority work). It may be called in the loop before performing a part of low-priority work.
func New ¶
func New() *PaceLimiter
New returns pace limiter that throttles WaitIfNeeded callers while the number of Inc calls is bigger than the number of Dec calls.
func (*PaceLimiter) DelaysTotal ¶
func (pl *PaceLimiter) DelaysTotal() uint64
DelaysTotal returns the number of delays inside WaitIfNeeded.
func (*PaceLimiter) WaitIfNeeded ¶
func (pl *PaceLimiter) WaitIfNeeded()
WaitIfNeeded blocks while the number of Inc calls is bigger than the number of Dec calls.