ratelimit

package
v0.0.0-...-d13da26 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Limiter

type Limiter interface {
	// Limit 有咩有触发限流。key 就是限流对象
	// bool 代表是否限流,true 就是要限流
	// err 限流器本身有咩有错误
	Limit(ctx context.Context, key string) (bool, error)
}

func NewRedisSlidingWindowLimiter

func NewRedisSlidingWindowLimiter(cmd redis.Cmdable,
	interval time.Duration, rate int) Limiter

type RedisSlidingWindowLimiter

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

RedisSlidingWindowLimiter Redis 上的滑动窗口算法限流器实现

func (*RedisSlidingWindowLimiter) Limit

func (r *RedisSlidingWindowLimiter) Limit(ctx context.Context, key string) (bool, error)

Directories

Path Synopsis
Package limitmocks is a generated GoMock package.
Package limitmocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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