basic

package
v0.0.0-...-ba76322 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListPermutations

func ListPermutations(arr []string) [][]string

Types

type LeakyBucket

type LeakyBucket struct {
	TimeIntervalMs int64
	RequestCount   int

	Lookup map[string]*list.List
}

func NewLeakyBucket

func NewLeakyBucket(RequestCount int, TimeIntervalMs int64) *LeakyBucket

func (*LeakyBucket) Cleanup

func (l *LeakyBucket) Cleanup(olderThanTs int64)

func (*LeakyBucket) IsAllowed

func (l *LeakyBucket) IsAllowed(key string, timestamp int64) bool

type TokenBucket

type TokenBucket struct {
	RefillIntervalSec int // 10 / sec
	RefillCount       int
	MaxCount          int

	LastUpdatedTs int
	CurrentCount  int

	sync.RWMutex
}

func NewTokenBucket

func NewTokenBucket(RefillInterval int, RefillCount int) *TokenBucket

func (*TokenBucket) IsRateLimited

func (t *TokenBucket) IsRateLimited(timestamp int) bool

Jump to

Keyboard shortcuts

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