rate

package
v1.3.90 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LimitLevel

type LimitLevel int
const (
	EnumLevelGlobal LimitLevel = iota
	EnumLevelUser
	EnumLevelClientId
	EnumLevelClientIp
)

type QpsLimiter

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

func NewQpsLimiter

func NewQpsLimiter(opts ...QpsOption) *QpsLimiter

Server ratelimiter middleware

func (*QpsLimiter) ClientIdAllow

func (l *QpsLimiter) ClientIdAllow(deviceId string) *QpsLimiter

func (*QpsLimiter) ClientIpAllow

func (l *QpsLimiter) ClientIpAllow(deviceIp string) *QpsLimiter

func (*QpsLimiter) GetOk

func (l *QpsLimiter) GetOk() bool

func (*QpsLimiter) GlobalAllow

func (l *QpsLimiter) GlobalAllow() *QpsLimiter

func (*QpsLimiter) OK

func (l *QpsLimiter) OK() bool

func (*QpsLimiter) SetOk

func (l *QpsLimiter) SetOk(ok bool)

func (*QpsLimiter) UserAllow

func (l *QpsLimiter) UserAllow(user string) *QpsLimiter

type QpsLimiterItem

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

type QpsOption

type QpsOption func(*QpsLimiter)

func QpsLimitOpt

func QpsLimitOpt(level LimitLevel, qps float64, burst int) QpsOption

WithWindow with window size.

type TpsLimiter

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

func GetTpsLimiter

func GetTpsLimiter(opts ...TpsOption) (*TpsLimiter, error)

func (*TpsLimiter) Release

func (tl *TpsLimiter) Release(n int) int

func (*TpsLimiter) TryAcquire

func (tl *TpsLimiter) TryAcquire(n int) bool

type TpsOption

type TpsOption func(*TpsLimiter)

func WithParal

func WithParal(paral int) TpsOption

func WithTag

func WithTag(tag string) TpsOption

WithWindow with window size.

Jump to

Keyboard shortcuts

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