ratelimit

package
v0.0.0-...-99221f3 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 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 要不要限流
	// 这是一种最简单的定义方式
	Limit(ctx context.Context, key string) (bool, error)
}

type RedisSlidingWindowLimiter

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

func NewRedisSlidingWindowLimiter

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

func (*RedisSlidingWindowLimiter) Limit

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

Directories

Path Synopsis
Code generated by MockGen.
Code generated by MockGen.

Jump to

Keyboard shortcuts

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