Documentation
¶
Index ¶
- Constants
- Variables
- func WaitN(ctx context.Context, estimated time.Time, duration time.Duration) error
- type Bucket
- type Limit
- type Limits
- type RateLimit
- func (r *RateLimit) CheckRetryAfter(route string, methodID string, headers http.Header) time.Duration
- func (r *RateLimit) MarshalZerologObject(encoder *zerolog.Event)
- func (r *RateLimit) Reserve(ctx context.Context, logger zerolog.Logger, route string, methodID string) error
- func (r *RateLimit) Update(logger zerolog.Logger, route string, methodID string, headers http.Header)
Constants ¶
View Source
const ( RATE_LIMIT_TYPE_HEADER = "X-Rate-Limit-Type" RETRY_AFTER_HEADER = "Retry-After" APP_RATE_LIMIT_HEADER = "X-App-Rate-Limit" APP_RATE_LIMIT_COUNT_HEADER = "X-App-Rate-Limit-Count" METHOD_RATE_LIMIT_HEADER = "X-Method-Rate-Limit" METHOD_RATE_LIMIT_COUNT_HEADER = "X-Method-Rate-Limit-Count" APP_RATE_LIMIT_TYPE = "application" METHOD_RATE_LIMIT_TYPE = "method" SERVICE_RATE_LIMIT_TYPE = "service" DEFAULT_RETRY_AFTER = 2 * time.Second )
Variables ¶
View Source
var (
ErrContextDeadlineExceeded = errors.New("waiting would exceed context deadline")
)
Functions ¶
Types ¶
type Bucket ¶
type Bucket struct {
// contains filtered or unexported fields
}
func (*Bucket) MarshalZerologObject ¶
type Limit ¶
type Limit struct {
// contains filtered or unexported fields
}
Limit represents a collection of buckets and the type of limit (application or method).
type RateLimit ¶
type RateLimit struct {
Route map[string]*Limits
Enabled bool
// Factor to be applied to the limit. E.g. if set to 0.5, the limit will be reduced by 50%.
LimitUsageFactor float64
// Delay in milliseconds to be add to reset intervals.
IntervalOverhead time.Duration
// contains filtered or unexported fields
}
func NewInternalRateLimit ¶ added in v0.19.3
func (*RateLimit) CheckRetryAfter ¶
func (r *RateLimit) CheckRetryAfter(route string, methodID string, headers http.Header) time.Duration
CheckRetryAfter returns the number of seconds to wait from the Retry-After header before retrying, or DEFAULT_RETRY_AFTER if not found.
func (*RateLimit) MarshalZerologObject ¶ added in v1.0.0
Click to show internal directories.
Click to hide internal directories.