grate

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLimitExceed = errors.New("limit exceed")
	ErrDeadline    = errors.New("deal line")
)

Functions

This section is empty.

Types

type CoDel

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

CoDel is CoDel req buffer queue.

func NewCoDel

func NewCoDel(opt ...CoDelOption) *CoDel

NewCoDel creates a CoDel queue.

func (*CoDel) Pop

func (q *CoDel) Pop()

Pop req from CoDel request buffer queue.

func (*CoDel) Push

func (q *CoDel) Push(ctx context.Context) (err error)

Push req into CoDel request buffer queue. if return error is nil,the caller must call q.Done() after finish request handling

func (*CoDel) Stats

func (q *CoDel) Stats() CoDelStats

Stats return the statistics of codel

type CoDelOption

type CoDelOption struct {
	Target   int64 // target queue delay (default 20 ms).
	Internal int64 // sliding minimum time window width (default 500 ms)
}

CoDelOption CoDel queue config.

type CoDelStats

type CoDelStats struct {
	Dropping bool
	FaTime   int64
	DropNext int64
	Packets  int
}

CoDelStats is the Statistics of CoDel queue.

type Limiter

type Limiter interface {
	Allow(ctx context.Context) (func(Operation), error)
}

Limiter limit interface.

func NewLimiter

func NewLimiter(c ...CoDelOption) Limiter

NewLimiter returns a new Limiter that allows events up to adaptive rtt.

type LogStatsFunc

type LogStatsFunc func()

type Operation

type Operation int

Operation operations type.

const (
	// Success operation type: success
	Success Operation = iota
	// Ignore operation type: ignore
	Ignore
	// Drop operation type: drop
	Drop
)

type Vegas

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

VegasLimiter tcp vegas.

func NewVegas

func NewVegas() *Vegas

NewVegas new a rate vegas.

func (*Vegas) Acquire

func (v *Vegas) Acquire() (done func(time.Time, Operation), success bool)

Acquire No matter success or not,done() must be called at last.

func (*Vegas) Stats

func (v *Vegas) Stats() VegasStats

Stats return the statistics of vegas.

type VegasStats

type VegasStats struct {
	Limit    int64
	InFlight int64
	MinRTT   time.Duration
	LastRTT  time.Duration
}

VegasStats is the Statistics of vegas.

Jump to

Keyboard shortcuts

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