bbr

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2021 License: MIT Imports: 6 Imported by: 50

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BBR

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

BBR implements bbr-like limiter. It is inspired by sentinel. https://github.com/alibaba/Sentinel/wiki/%E7%B3%BB%E7%BB%9F%E8%87%AA%E9%80%82%E5%BA%94%E9%99%90%E6%B5%81

func NewLimiter

func NewLimiter(opts ...Option) *BBR

NewLimiter returns a bbr limiter

func (*BBR) Allow

func (l *BBR) Allow() (ratelimit.DoneFunc, error)

Allow checks all inbound traffic. Once overload is detected, it raises limit.ErrLimitExceed error.

func (*BBR) Stat

func (l *BBR) Stat() Stat

Stat tasks a snapshot of the bbr limiter.

type Option

type Option func(*options)

Option function for bbr limiter

func WithBucket

func WithBucket(b int) Option

WithBucket with bucket ize.

func WithCPUThreshold

func WithCPUThreshold(threshold int64) Option

WithCPUThreshold with cpu threshold;

func WithWindow

func WithWindow(d time.Duration) Option

WithWindow with window size.

type Stat

type Stat struct {
	CPU         int64
	InFlight    int64
	MaxInFlight int64
	MinRt       int64
	MaxPass     int64
}

Stat contains the metrics snapshot of bbr.

Jump to

Keyboard shortcuts

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