ratelimiting

package
v0.0.0-...-0b61f1f Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2020 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

View Source
const (
	LUA_SCRIPT_LEAKY_BUCKET = `` /* 132-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func NewRedisLeakyBucketImpl

func NewRedisLeakyBucketImpl(cfg *RedisLeakyBucketImplConfig) *redisLeakyBucketImpl

Types

type FixedWindow

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

func NewFixedWindow

func NewFixedWindow(rate uint64, duration time.Duration) *FixedWindow

func (*FixedWindow) Teke

func (f *FixedWindow) Teke() time.Time

type LeakyBucket

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

func NewLeakyBucket

func NewLeakyBucket(rate uint64, duration time.Duration) *LeakyBucket

func (*LeakyBucket) Take

func (l *LeakyBucket) Take() time.Time

type RateLimitingInf

type RateLimitingInf interface {
	Take(string) (*Result, error)
	GetLimit() int
	GetPeriod() time.Duration
}

type RedisLeakyBucketImplConfig

type RedisLeakyBucketImplConfig struct {
	RPool  *redis.Pool
	Limit  int
	Period time.Duration
}

type Result

type Result struct {
	Remaining int
	Reset     int64
}

Jump to

Keyboard shortcuts

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