Pkg
Ratelimit

Ratelimit

Explore the following sections to learn more:

ratelimit

import "github.com/gemini-oss/rego/pkg/common/ratelimit"

pkg/common/ratelimit/ratelimit.go

Index

type RateLimiter

RateLimiter struct defines the fields for the rate limiter

type RateLimiter struct {
    Available      int           // Available requests remaining
    Limit          int           // Total requests allowed in the interval
    Interval       time.Duration // Interval to reset the rate limiter
    Requests       int           // Total requests made
    ResetHeaders   bool          // Flag to check if the rate limiter retrieves info from specific headers
    ResetTimestamp int64         // Timestamp to reset the rate limiter
    RetryAfter     int           // Retry after time
    TimeUntilReset time.Duration // Time until the rate limiter resets
    UsesRetryAfter bool          // Flag to check if the rate limiter uses a retry after value
    Log            *log.Logger   // Logger for the rate limiter
    // contains filtered or unexported fields
}

func NewRateLimiter

func NewRateLimiter(args ...interface{}) *RateLimiter

NewRateLimiter creates a new RateLimiter instance with the given parameters

func (*RateLimiter) Start

func (rl *RateLimiter) Start()

Start begins the rate limiter’s internal timer

func (*RateLimiter) Stop

func (rl *RateLimiter) Stop()

Stop terminates the rate limiter’s internal timer

func (*RateLimiter) UpdateFromHeaders

func (rl *RateLimiter) UpdateFromHeaders(headers http.Header)

func (*RateLimiter) Wait

func (rl *RateLimiter) Wait()

Throttle requests based on the remaining available rate limit.

Generated by gomarkdoc