Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdaptiveRateLimiter ¶
type AdaptiveRateLimiter struct {
// contains filtered or unexported fields
}
func NewAdaptiveRateLimiter ¶
func NewAdaptiveRateLimiter(backendLimiter RateLimiter, initialRqs int, totalRqs int) *AdaptiveRateLimiter
func (*AdaptiveRateLimiter) AdaptiveLimit ¶
func (r *AdaptiveRateLimiter) AdaptiveLimit() int
func (*AdaptiveRateLimiter) Limit ¶
func (r *AdaptiveRateLimiter) Limit() int
func (*AdaptiveRateLimiter) SetLimit ¶
func (r *AdaptiveRateLimiter) SetLimit(newLimit int) error
type BackendError ¶
type BackendError struct {
Source error
}
func (*BackendError) Error ¶
func (e *BackendError) Error() string
func (*BackendError) Unwrap ¶
func (e *BackendError) Unwrap() error
type ContextCancelled ¶ added in v0.3.0
type ContextCancelled struct {
}
func (*ContextCancelled) Error ¶ added in v0.3.0
func (e *ContextCancelled) Error() string
type InMemoryBackendLimiter ¶
InMemoryBackendLimiter is only for testing/unit test purpose
func NewInMemoryBackendLimiter ¶
func NewInMemoryBackendLimiter(tid tenant.Id, rqs int) *InMemoryBackendLimiter
func (*InMemoryBackendLimiter) Limit ¶
func (r *InMemoryBackendLimiter) Limit() int
func (*InMemoryBackendLimiter) SetLimit ¶
func (r *InMemoryBackendLimiter) SetLimit(newLimit int) error
type InvalidUnitError ¶
type InvalidUnitError struct {
BadUnit int
}
func (*InvalidUnitError) Error ¶
func (e *InvalidUnitError) Error() string
type LimitReached ¶
type LimitReached struct {
}
func (*LimitReached) Error ¶
func (e *LimitReached) Error() string
type RateLimiter ¶
type RateLimiter interface {
//Take given units
//Returns LimitReached if limit reached
//Returns InvalidUnitError if unit <= 0 or > the max limit
Take(ctx context.Context, unit int) error
//Limit gets the current limit
Limit() int
//SetLimit sets the limit. 0 means there is no limit
//Returns InvalidUnitError if newLimit < 0
SetLimit(newLimit int) error
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.