Documentation ¶
Index ¶
- Variables
- func Allow(ctx context.Context, namespace string, size int, isWrite bool) error
- func Cleanup()
- func Init(tm *metadata.TenantManager, cfg *config.Config) error
- func Wait(ctx context.Context, namespace string, size int, isWrite bool) error
- type Backend
- type Datadog
- type Limiter
- type LimiterConfig
- type Manager
- type NoopMetrics
- type Quota
- type State
Constants ¶
This section is empty.
Variables ¶
var ( ErrReadUnitsExceeded = errors.ResourceExhausted("request read rate exceeded") ErrWriteUnitsExceeded = errors.ResourceExhausted("request write rate exceeded") ErrStorageSizeExceeded = errors.ResourceExhausted("data size limit exceeded") ErrMaxRequestSizeExceeded = errors.ResourceExhausted("maximum request size limit exceeded") )
var RunningAverageLength = 60 * time.Second
Functions ¶
Types ¶
type Limiter ¶
func (*Limiter) Allow ¶
Allow checks if the request with given size can be executed at this moment. It returns immediately. If no error returned the request is allowed to proceed. In the case of error, it returns specific error indicating, which limiter parameter is violated, whether read or write.
func (*Limiter) Wait ¶
Wait checks if the request with given size can be executed at this moment. It returns immediately if the request allowed to proceed. But, in the case of limits violation, unlike Allow, it doesn't return immediately, but reserves a token and delays the execution till the moment when request can proceed without violating the limits. The execution can be delayed upto the timeout set in the context.
type LimiterConfig ¶
type NoopMetrics ¶
type NoopMetrics struct{}