requestblocker

package
v1.0.17 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

请求阻拦器 可用于限制用户的每秒最大请求数等场景 by:liangliangit

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RequestBlock

type RequestBlock struct {
	RequestTimeLast int64 //最近一次的请求时间
	RequestCount    int64 //请求次数
	BlockCountLimit int64 //请求数量限定次数
	BlockTime       int64 //被锁定的时间点
	time.Timer
}

type RequestBlocker

type RequestBlocker struct {
	sync.Mutex

	ResetTimeleft   int64 //CD冷却锁定时间
	BlockCountLimit int64 //请求锁定阀值
	// contains filtered or unexported fields
}

func New

func New(ResetTimeleft, BlockCountLimit int64) *RequestBlocker

func (*RequestBlocker) Request

func (l *RequestBlocker) Request(feature string) bool

Jump to

Keyboard shortcuts

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