calllimit

package
v0.0.0-...-20d904f Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallLimit

type CallLimit struct {
	// contains filtered or unexported fields
}
var CallStatics *CallLimit

func NewCallLimit

func NewCallLimit(histCount int) *CallLimit

func (*CallLimit) Call

func (me *CallLimit) Call(key string) Limit

func (*CallLimit) Get

func (me *CallLimit) Get(key string) Limit

func (*CallLimit) IsLocked

func (me *CallLimit) IsLocked(name string) bool

func (*CallLimit) SetLockTime

func (me *CallLimit) SetLockTime(name string, sec int64)

type Limit

type Limit struct {
	Key              string //统计的关键字
	LimitCountPerMin int    //限制调用次数/分钟
	LimitCountPerSec int    //限制调用次数/秒
	LastCallTime     int64  //最后成功调用
	CallCount        int64  //统计所有调用
	LockTime         int64
	CallHist         list.List `json:"-"` //统计历史次数, 默认60分钟 *LimitItem
}

type LimitItem

type LimitItem struct {
	Key        string
	CreateTime int64
	Count      int64
}

func (*LimitItem) IsLimit

func (me *LimitItem) IsLimit() bool

Jump to

Keyboard shortcuts

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