rate

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2022 License: LGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLimiterPerID

func NewLimiterPerID(rate rate.Limit, burst int, c *Config) *limiterPerID

NewLimiterPerID creates a limit limiter based on ID

Types

type Config

type Config struct {
	Capacity    *int
	CheckInt    *time.Duration
	MinEvictDur *time.Duration
	Whitelist   []string
}

Config is the config for Limiter

type IDLimiter

type IDLimiter interface {
	AllowN(id string, n int) bool
	WaitN(ctx context.Context, id string, n int) error
}

IDLimiter is the limiter interface to limit incoming traffics per ID

Jump to

Keyboard shortcuts

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