ratelimit

package
v0.0.0-...-f382dc8 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2022 License: GPL-3.0 Imports: 7 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 struct {
	// 限流器 名称
	Name string
	// contains filtered or unexported fields
}

Limiter 限流器结构定义

func NewLimiter

func NewLimiter(name string, rateLimitEvery int, rateLimitBucket int) *Limiter

NewLimiter 创建限流器 rateLimitEvery 每秒产生多少个令牌 rateLimitBucket 令牌桶大小

func (*Limiter) RequestLimitUnique

func (l *Limiter) RequestLimitUnique(ctx context.Context) error

RequestLimitUnique 检测是否限流 NOTE: 可传 context 上下文

Jump to

Keyboard shortcuts

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