limiter

package
v0.0.0-...-6d97e55 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SHARDS = uint64(128)

Functions

func TimeTrack

func TimeTrack(start time.Time, name string)

Types

type RateLimiter

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

func NewRateLimiter

func NewRateLimiter() *RateLimiter

func (*RateLimiter) GetShard

func (l *RateLimiter) GetShard(key int64) *Shard

func (*RateLimiter) Len

func (l *RateLimiter) Len() int64

func (*RateLimiter) Reduce

func (l *RateLimiter) Reduce(key string, maxTokens int64, refillTime int64, refillAmount int64, tokens int64) (int64, error)

func (*RateLimiter) Remove

func (l *RateLimiter) Remove(key string)

type Shard

type Shard struct {
	Values      map[int64]int64
	LastUpdates map[int64]int64
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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