bbr

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

README

bbr

import "github.com/ccheers/xpkg/ratelimit/bbr"

Index

Variables

var ErrLimitExceed = fmt.Errorf("limit exceed")

type BBR

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

type BBR struct {
    // contains filtered or unexported fields
}
func (*BBR) Allow
func (l *BBR) Allow(ctx context.Context, opts ...limit.AllowOption) (func(info limit.DoneInfo), error)

Allow checks all inbound traffic. Once overload is detected, it raises ecode.LimitExceed error.

func (*BBR) Stat
func (l *BBR) Stat() Stat

Stat tasks a snapshot of the bbr limiter.

type Config

Config contains configs of bbr limiter.

type Config struct {
    Enabled      bool
    Window       time.Duration
    WinBucket    int
    Rule         string
    Debug        bool
    CPUThreshold int64
}

type CounterCache

CounterCache is used to cache maxPASS and minRt result. Value of current bucket is not counted in real time. Cache time is equal to a bucket duration.

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

type Group

Group represents a class of BBRLimiter and forms a namespace in which units of BBRLimiter.

type Group struct {
    // contains filtered or unexported fields
}
func NewGroup
func NewGroup(conf *Config) *Group

NewGroup new a limiter group container, if conf nil use default conf.

func (*Group) Get
func (g *Group) Get(key string) limit.Limiter

Get get a limiter by a specified key, if limiter not exists then make a new one.

type Stat

Stat contains the metrics's snapshot of bbr.

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

Generated by gomarkdoc

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrLimitExceed = fmt.Errorf("limit exceed")

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 (*BBR) Allow

func (l *BBR) Allow(ctx context.Context, opts ...limit.AllowOption) (func(info limit.DoneInfo), error)

Allow checks all inbound traffic. Once overload is detected, it raises ecode.LimitExceed error.

func (*BBR) Stat

func (l *BBR) Stat() Stat

Stat tasks a snapshot of the bbr limiter.

type Config

type Config struct {
	Enabled      bool
	Window       time.Duration
	WinBucket    int
	Rule         string
	Debug        bool
	CPUThreshold int64
}

Config contains configs of bbr limiter.

type CounterCache

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

CounterCache is used to cache maxPASS and minRt result. Value of current bucket is not counted in real time. Cache time is equal to a bucket duration.

type Group

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

Group represents a class of BBRLimiter and forms a namespace in which units of BBRLimiter.

func NewGroup

func NewGroup(conf *Config) *Group

NewGroup new a limiter group container, if conf nil use default conf.

func (*Group) Get

func (g *Group) Get(key string) limit.Limiter

Get get a limiter by a specified key, if limiter not exists then make a new one.

type Stat

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

Stat contains the metrics's snapshot of bbr.

Jump to

Keyboard shortcuts

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