redis

package
v0.0.0-...-b2e13bb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFixedWindowLimiter

func NewFixedWindowLimiter(client *redis.Client, limit int, window time.Duration) (ratelimit.RedisLimiter, error)

func NewLeakyBucketLimiter

func NewLeakyBucketLimiter(client *redis.Client, peakLevel, currentVelocity int) ratelimit.RedisLimiter

func NewSlidingLogLimiter

func NewSlidingLogLimiter(client *redis.Client, smallWindow time.Duration, strategies ...*SlidingLogLimiterStrategy) (
	ratelimit.RedisLimiter, error)

func NewSlidingWindowLimiter

func NewSlidingWindowLimiter(client *redis.Client, limit int, window, smallWindow time.Duration) (
	ratelimit.RedisLimiter, error)

func NewTokenBucketLimiter

func NewTokenBucketLimiter(client *redis.Client, capacity, rate int) ratelimit.RedisLimiter

Types

type SlidingLogLimiterStrategy

type SlidingLogLimiterStrategy struct {
	// contains filtered or unexported fields
}

SlidingLogLimiterStrategy 滑动日志限流器的策略

func NewSlidingLogLimiterStrategy

func NewSlidingLogLimiterStrategy(limit int, window time.Duration) *SlidingLogLimiterStrategy

type ViolationStrategyError

type ViolationStrategyError struct {
	Limit  int           // 窗口请求上限
	Window time.Duration // 窗口时间大小
}

ViolationStrategyError 违背策略错误

func (*ViolationStrategyError) Error

func (e *ViolationStrategyError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL