ratelimit

package
v0.12.6 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2025 License: MIT Imports: 14 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cfg added in v0.11.0

type Cfg struct {
	Type Type `json:"type" yaml:"type"`
	Cfg  any  `json:"cfg"  yaml:"cfg"`
}

func (*Cfg) UnmarshalJSON added in v0.11.0

func (c *Cfg) UnmarshalJSON(data []byte) error

func (*Cfg) UnmarshalYAML added in v0.11.0

func (c *Cfg) UnmarshalYAML(data []byte) error

type FixedRateLimiter

type FixedRateLimiter struct {
	runner.Runner
	*FixedRateLimiterCfg
	// contains filtered or unexported fields
}

func NewFixedRateLimiter

func NewFixedRateLimiter() *FixedRateLimiter

func (*FixedRateLimiter) Init

func (frl *FixedRateLimiter) Init() error

func (*FixedRateLimiter) RxWaitN

func (frl *FixedRateLimiter) RxWaitN(ctx context.Context, n int, timeout time.Duration) error

func (*FixedRateLimiter) SetRxLimit added in v0.11.37

func (frl *FixedRateLimiter) SetRxLimit(n int, burst int)

func (*FixedRateLimiter) SetTxLimit added in v0.11.37

func (frl *FixedRateLimiter) SetTxLimit(n int, burst int)

func (*FixedRateLimiter) TxWaitN

func (frl *FixedRateLimiter) TxWaitN(ctx context.Context, n int, timeout time.Duration) error

type FixedRateLimiterCfg

type FixedRateLimiterCfg struct {
	N     int
	Burst int
}

func NewFixedRateLimiterCfg

func NewFixedRateLimiterCfg() *FixedRateLimiterCfg

type HostRateLimiter

type HostRateLimiter struct {
	runner.Runner
	*HostRateLimiterCfg
	// contains filtered or unexported fields
}

func NewHostRateLimiter

func NewHostRateLimiter() *HostRateLimiter

func (*HostRateLimiter) Init

func (h *HostRateLimiter) Init() error

func (*HostRateLimiter) NicSpeedMBps added in v0.11.52

func (h *HostRateLimiter) NicSpeedMBps() int

func (*HostRateLimiter) RxWaitN

func (h *HostRateLimiter) RxWaitN(ctx context.Context, n int, timeout time.Duration) error

func (*HostRateLimiter) TxWaitN

func (h *HostRateLimiter) TxWaitN(ctx context.Context, n int, timeout time.Duration) error

type HostRateLimiterCfg

type HostRateLimiterCfg struct {
	Nic             string `json:"nic"              yaml:"nic"               validate:"required"`
	MonitorInterval int    `json:"monitorInterval"  yaml:"monitorInterval"   validate:"required"`
	MaxPercent      int    `json:"maxPercent"       yaml:"maxPercent"        validate:"gte=0,lte=100"`
	MaxMBps         int    `json:"maxMBps"          yaml:"maxMBps"`
	MinMBps         int    `json:"minMBps"          yaml:"minMBps"           validate:"gte=0"`
}

func NewHostRateLimiterCfg

func NewHostRateLimiterCfg() *HostRateLimiterCfg

type RxTxRateLimiter

type RxTxRateLimiter interface {
	runner.Runner
	plugin.Plugin
	RxWaitN(ctx context.Context, n int, timeout time.Duration) error
	TxWaitN(ctx context.Context, n int, timeout time.Duration) error
}

type SleepRateLimiter

type SleepRateLimiter struct {
	runner.Runner
	*SleepRateLimiterCfg
}

func NewSleepRateLimiter

func NewSleepRateLimiter() *SleepRateLimiter

func (*SleepRateLimiter) Init

func (srl *SleepRateLimiter) Init() error

func (*SleepRateLimiter) RxWaitN

func (srl *SleepRateLimiter) RxWaitN(ctx context.Context, n int, timeout time.Duration) error

func (*SleepRateLimiter) TxWaitN

func (srl *SleepRateLimiter) TxWaitN(ctx context.Context, n int, timeout time.Duration) error

type SleepRateLimiterCfg

type SleepRateLimiterCfg struct {
	Microsecond int
}

func NewSleepRateLimiterCfg

func NewSleepRateLimiterCfg() *SleepRateLimiterCfg

type Type added in v0.11.0

type Type string
const TypeFixed Type = "fixed"
const TypeHost Type = "host"
const TypeSleep Type = "sleep"

Jump to

Keyboard shortcuts

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