reqlimiter

package
v0.0.0-...-fef60ef Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LimiterConfig

type LimiterConfig struct {
	TTL           time.Duration
	CleanInterval time.Duration
	Rate          int
}

func NewLimiterConfig

func NewLimiterConfig(rate int) LimiterConfig

NewLimiterConfig create default limiter configuration.

type ReqLimiter

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

func NewReqLimiter

func NewReqLimiter(cfg LimiterConfig) *ReqLimiter

NewReqLimiter create new instance of ReqLimiter.

func (*ReqLimiter) Allow

func (r *ReqLimiter) Allow(key string) bool

Allow check allow or not action by limits.

func (*ReqLimiter) HasKey

func (r *ReqLimiter) HasKey(key string) bool

func (*ReqLimiter) Remove

func (r *ReqLimiter) Remove(key string)

Remove remove bucket.

Jump to

Keyboard shortcuts

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