Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DistributedRateLimiter ¶
type DistributedRateLimiter interface { // TokenBucket returns a token bucket rate limiter. TokenBucket(ctx context.Context, capacity int64, per time.Duration) *limiters.TokenBucket }
DistributedRateLimiter is an interface for a distributed rate limiter.
func NewDistributedRateLimiter ¶
func NewDistributedRateLimiter(rdb redis.UniversalClient, key string) DistributedRateLimiter
NewDistributedRateLimiter creates a new instance of DistributedRateLimiter.
type JobRateLimiter ¶
type JobRateLimiter interface { // TakeByClusterID takes a token from the rate limiter by cluster ID, returns the time to wait // until the next token is available. TakeByClusterID(ctx context.Context, clusterID uint, tokens int64) (time.Duration, error) // TakeByClusterIDs takes a token from the rate limiter by cluster IDs, returns the time to wait // until the next token is available. If only one cluster is reatcted the limit, return the // time to wait. TakeByClusterIDs(ctx context.Context, clusterIDs []uint, tokens int64) (time.Duration, error) // Serve started job rate limiter server. Serve() // Stop job rate limiter server. Stop() }
JobRateLimiter is an interface for a job rate limiter.
func NewJobRateLimiter ¶
func NewJobRateLimiter(database *database.Database) (JobRateLimiter, error)
NewJobRateLimiter creates a new instance of JobRateLimiter.
Click to show internal directories.
Click to hide internal directories.