Documentation
¶
Index ¶
- type LimitLevel
- type QpsLimiter
- func (l *QpsLimiter) ClientIdAllow(deviceId string) *QpsLimiter
- func (l *QpsLimiter) ClientIpAllow(deviceIp string) *QpsLimiter
- func (l *QpsLimiter) GetOk() bool
- func (l *QpsLimiter) GlobalAllow() *QpsLimiter
- func (l *QpsLimiter) OK() bool
- func (l *QpsLimiter) SetOk(ok bool)
- func (l *QpsLimiter) UserAllow(user string) *QpsLimiter
- type QpsLimiterItem
- type QpsOption
- type TpsLimiter
- type TpsOption
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
Click to show internal directories.
Click to hide internal directories.