ratelimit

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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(n int, timeout int) error

func (*FixedRateLimiter) TxWaitN

func (frl *FixedRateLimiter) TxWaitN(n int, timeout int) error

type FixedRateLimiterCfg

type FixedRateLimiterCfg struct {
	N 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) RxWaitN

func (h *HostRateLimiter) RxWaitN(n int, timeout int) error

func (*HostRateLimiter) TxWaitN

func (h *HostRateLimiter) TxWaitN(n int, timeout int) error

type HostRateLimiterCfg

type HostRateLimiterCfg struct {
	Nic             string `json:"nic"             validate:"required,min=1" yaml:"nic"`
	MonitorInterval int    `json:"monitorInterval" yaml:"monitorInterval"`
	ReservePercent  int    `json:"reservePercent"  yaml:"reservePercent"`
	MinMBps         int    `json:"minMBps"         yaml:"minMBps"`
	FixedMBps       int    `json:"fixedMBps"       yaml:"fixedMBps"`
}

func NewHostRateLimiterCfg

func NewHostRateLimiterCfg() *HostRateLimiterCfg

type RateLimiterCfg

type RateLimiterCfg struct {
	Cfg  interface{}     `json:"cfg"  yaml:"cfg"`
	Type RateLimiterType `json:"type" yaml:"type"`
}

type RateLimiterType

type RateLimiterType string
const RateLimiterTypeFixed RateLimiterType = "fixed"
const RateLimiterTypeHost RateLimiterType = "host"
const RateLimiterTypeSleep RateLimiterType = "sleep"

type RxTxRateLimiter

type RxTxRateLimiter interface {
	runner.Runner
	RxWaitN(n int, timeout int) error
	TxWaitN(n int, timeout int) 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(n int, timeout int) error

func (*SleepRateLimiter) TxWaitN

func (srl *SleepRateLimiter) TxWaitN(n int, timeout int) error

type SleepRateLimiterCfg

type SleepRateLimiterCfg struct {
	Millisecond int
}

func NewSleepRateLimiterCfg

func NewSleepRateLimiterCfg() *SleepRateLimiterCfg

Jump to

Keyboard shortcuts

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