limit

package
v0.0.0-...-cb950d2 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QPSStrategy         = "QPS"
	RateLimiterStrategy = "RateLimiter"
)

limit strategy

Variables

This section is empty.

Functions

This section is empty.

Types

type LimitEngine

type LimitEngine struct {
	RuleConfig *model.RuleConfig
	// contains filtered or unexported fields
}

LimitEngine limit

func NewLimitEngine

func NewLimitEngine(ruleConfig *model.RuleConfig) (*LimitEngine, error)

NewLimitEngine limit

func (*LimitEngine) OverLimit

func (engine *LimitEngine) OverLimit() bool

OverLimit check limit

type Limiter

type Limiter interface {
	TryAcquire() bool
}

Limiter limit

type QPSLimiter

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

QPSLimiter limiter

func NewQPSLimiter

func NewQPSLimiter(maxAllows int64, periodMs int64) (*QPSLimiter, error)

NewQPSLimiter new

func (*QPSLimiter) TryAcquire

func (l *QPSLimiter) TryAcquire() bool

TryAcquire limit

type RateLimiter

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

RateLimiter limit

func NewRateLimiter

func NewRateLimiter(maxAllows int64, periodMs int64, MaxBurstRatio float64) (*RateLimiter, error)

NewRateLimiter new

func (*RateLimiter) TryAcquire

func (l *RateLimiter) TryAcquire() bool

TryAcquire limit

Jump to

Keyboard shortcuts

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