rate

package
v0.0.0-...-4450389 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StartRateFactor   = 3
	IncreaseSteps     = 100
	DecreaseFactor    = 0.75
	IncreaseThreshold = 0.6
	DecreaseThreshold = 0.1
	RegulateEveryNTau = 3
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Name    string
	MinRate rate.Limit
	MaxRate rate.Limit
	Burst   int
	Tau     time.Duration
}

type Limiter

type Limiter struct {
	L *rate.Limiter
	// contains filtered or unexported fields
}

func NewLimiter

func NewLimiter(lg Logger, cfg Config) *Limiter

func (*Limiter) Excess

func (lim *Limiter) Excess()

func (*Limiter) ExcessRate

func (lim *Limiter) ExcessRate() float64

func (*Limiter) Regulate

func (lim *Limiter) Regulate(ctx context.Context) error

func (*Limiter) Success

func (lim *Limiter) Success()

func (*Limiter) SuccessRate

func (lim *Limiter) SuccessRate() float64

type Logger

type Logger interface {
	Infow(msg string, kv ...interface{})
}

Jump to

Keyboard shortcuts

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