shaper

package
v0.62.1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v0.55.0

type Config struct {
	Name        string `fig:"name"`
	MaxSessions int    `fig:"max_sessions" default:"10"`
	Rate        struct {
		Limit int `fig:"limit" default:"1000"`
		Burst int `fig:"burst" default:"0"`
	} `fig:"rate"`
	Matching struct {
		JID struct {
			In    []string `fig:"in"`
			RegEx string   `fig:"regex"`
		}
	} `fig:"matching"`
}

Config contains Shaper configuration parameters.

type Shaper

type Shaper struct {
	// Name is the shaper name.
	Name string

	// MaxSessions represents maximum sessions count.
	MaxSessions int
	// contains filtered or unexported fields
}

Shaper represents a connection traffic constraint set.

func New

func New(cfg Config) (Shaper, error)

New returns a new Shaper given a configuration.

func (*Shaper) RateLimiter

func (s *Shaper) RateLimiter() *rate.Limiter

RateLimiter returns a new rate limiter configured with shaper parameters.

type Shapers

type Shapers []Shaper

Shapers represents a shaper collection ordered by priority.

func (Shapers) DefaultC2S

func (ss Shapers) DefaultC2S() *Shaper

DefaultC2S returns C2S default shaper.

func (Shapers) DefaultS2S

func (ss Shapers) DefaultS2S() *Shaper

DefaultS2S returns S2S default shaper.

func (Shapers) MatchingJID

func (ss Shapers) MatchingJID(j *jid.JID) *Shaper

MatchingJID returns the shaper that should be applied to a given JID.

Jump to

Keyboard shortcuts

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