Documentation ¶
Index ¶
- type BasicRateLimitChecker
- func (l *BasicRateLimitChecker) AddOverride(label string, scaleFactor float64)
- func (l *BasicRateLimitChecker) CheckRateLimit(label string, count int) (bool, int)
- func (l *BasicRateLimitChecker) GetLabelRateLimit(label string) int
- func (l *BasicRateLimitChecker) GetRateLimit() int
- func (l *BasicRateLimitChecker) RemoveOverride(label string)
- func (l *BasicRateLimitChecker) SetRateLimit(limit int)
- type DistCacheRateTracker
- func (ol *DistCacheRateTracker) Close() error
- func (ol *DistCacheRateTracker) GetRateLimitChecker() RateLimitChecker
- func (ol *DistCacheRateTracker) Name() string
- func (ol *DistCacheRateTracker) Take(label string) (bool, int, int)
- func (ol *DistCacheRateTracker) TakeN(label string, n int) (bool, int, int)
- type LazySyncRateTracker
- func (lsl *LazySyncRateTracker) Close() error
- func (lsl *LazySyncRateTracker) GetRateLimitChecker() RateLimitChecker
- func (lsl *LazySyncRateTracker) Name() string
- func (lsl *LazySyncRateTracker) Take(label string) (bool, int, int)
- func (lsl *LazySyncRateTracker) TakeN(label string, n int) (bool, int, int)
- type RateLimitChecker
- type RateTracker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasicRateLimitChecker ¶
type BasicRateLimitChecker struct {
// contains filtered or unexported fields
}
BasicRateLimitChecker implements LimitCheck.
func NewBasicRateLimitChecker ¶
func NewBasicRateLimitChecker() *BasicRateLimitChecker
NewBasicRateLimitChecker creates a new instance of BasicLimitCheck.
func (*BasicRateLimitChecker) AddOverride ¶
func (l *BasicRateLimitChecker) AddOverride(label string, scaleFactor float64)
AddOverride sets the limit for a specific label.
func (*BasicRateLimitChecker) CheckRateLimit ¶
func (l *BasicRateLimitChecker) CheckRateLimit(label string, count int) (bool, int)
CheckRateLimit checks the limit for a specific label and the remaining limit. If limit is exceeded then we return false and 0 as remaining limit.
func (*BasicRateLimitChecker) GetLabelRateLimit ¶
func (l *BasicRateLimitChecker) GetLabelRateLimit(label string) int
GetLabelRateLimit returns the limit for a specific label.
func (*BasicRateLimitChecker) GetRateLimit ¶
func (l *BasicRateLimitChecker) GetRateLimit() int
GetRateLimit returns the limit.
func (*BasicRateLimitChecker) RemoveOverride ¶
func (l *BasicRateLimitChecker) RemoveOverride(label string)
RemoveOverride removes the limit for a specific label.
func (*BasicRateLimitChecker) SetRateLimit ¶
func (l *BasicRateLimitChecker) SetRateLimit(limit int)
SetRateLimit sets the limit.
type DistCacheRateTracker ¶ added in v0.1.2
type DistCacheRateTracker struct {
// contains filtered or unexported fields
}
DistCacheRateTracker implements Limiter.
func (*DistCacheRateTracker) Close ¶ added in v0.1.2
func (ol *DistCacheRateTracker) Close() error
Close cleans up DMap held within the DistCacheRateTracker.
func (*DistCacheRateTracker) GetRateLimitChecker ¶ added in v0.1.2
func (ol *DistCacheRateTracker) GetRateLimitChecker() RateLimitChecker
GetRateLimitChecker returns the RateLimitCheck of the DistCacheRateTracker.
func (*DistCacheRateTracker) Name ¶ added in v0.1.2
func (ol *DistCacheRateTracker) Name() string
Name returns the name of the DistCacheRateTracker.
func (*DistCacheRateTracker) Take ¶ added in v0.1.2
func (ol *DistCacheRateTracker) Take(label string) (bool, int, int)
Take is a wrapper for TakeN(label, 1).
type LazySyncRateTracker ¶
type LazySyncRateTracker struct {
// contains filtered or unexported fields
}
LazySyncRateTracker is a limiter that syncs its state lazily with another limiter.
func (*LazySyncRateTracker) Close ¶
func (lsl *LazySyncRateTracker) Close() error
Close closes the limiter.
func (*LazySyncRateTracker) GetRateLimitChecker ¶
func (lsl *LazySyncRateTracker) GetRateLimitChecker() RateLimitChecker
GetRateLimitChecker returns the limit checker of the limiter.
func (*LazySyncRateTracker) Name ¶
func (lsl *LazySyncRateTracker) Name() string
Name returns the name of the limiter.
type RateLimitChecker ¶
type RateLimitChecker interface { CheckRateLimit(label string, count int) (ok bool, remaining int) SetRateLimit(limit int) GetRateLimit() int }
RateLimitChecker is a generic limit checker interface.
type RateTracker ¶
type RateTracker interface { Name() string Take(label string) (ok bool, remaining int, current int) TakeN(label string, count int) (ok bool, remaining int, current int) GetRateLimitChecker() RateLimitChecker Close() error }
RateTracker is a generic limiter interface.
func NewDistCacheRateTracker ¶ added in v0.1.2
func NewDistCacheRateTracker(limitCheck RateLimitChecker, dc *distcache.DistCache, name string, ttl time.Duration) (RateTracker, error)
NewDistCacheRateTracker creates a new instance of DistCacheRateTracker.
func NewLazySyncRateTracker ¶
func NewLazySyncRateTracker(limiter RateTracker, syncDuration time.Duration, jobGroup *jobs.JobGroup, ) (RateTracker, error)
NewLazySyncRateTracker creates a new LazySyncLimiter.