Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter limits per-second rate of arbitrary resources.
Call Register() for registering the given amounts of resources.
func New ¶
func New(perSecondLimit int64, limitReached *metrics.Counter, stopCh <-chan struct{}) *RateLimiter
New creates new rate limiter with the given perSecondLimit.
stopCh is used for unblocking Register() calls when the rate limiter is no longer needed.
func (*RateLimiter) Register ¶
func (rl *RateLimiter) Register(count int)
Register registers count resources.
Register blocks if the given per-second rate limit is exceeded. It may be forcibly unblocked by closing stopCh passed to New().
Click to show internal directories.
Click to hide internal directories.