payload

package
v1.6.0-rc.5 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2023 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdaptiveLimiterConfig

type AdaptiveLimiterConfig struct {
	// FreeMemThresholdLimit is the threshold for the free memory in percentage. Default is 30%
	FreeMemThresholdLimit float64
	// CriticalFreeMemory is the critical threshold for the free memory in percentage. Default is 10%
	FreeMemCriticalLimit float64
	// MaxThresholdFactor is the maximum threshold factor. Values 1-9 are valid. Default is 9
	MaxThresholdFactor int
	// FreeMemory is the function to use for getting the free memory in percentage. Default implementation will be used if not provided
	FreeMemory FreeMemory
	// Log
	Log logger.Logger
}

type AdaptiveLimiterFunc

type AdaptiveLimiterFunc func(int64) int64

func SetupAdaptiveLimiter

func SetupAdaptiveLimiter(ctx context.Context, g *errgroup.Group) AdaptiveLimiterFunc

SetupAdaptiveLimiter creates a new AdaptiveLimiter, starts its RunLoop in a goroutine and periodically collects statistics.

type FreeMemory

type FreeMemory func() (float64, error)

FreeMemory is a function that returns the free memory in percentage (0-100)

type Limiter

type Limiter interface {
	RunLoop(ctx context.Context, frequency func() <-chan time.Time)
	Limit(maxLimit int64) int64
	Stats() LimiterStats
	// contains filtered or unexported methods
}

Limit is a function that returns the current payload limit in bytes

func NewAdaptiveLimiter

func NewAdaptiveLimiter(config AdaptiveLimiterConfig) Limiter

NewAdaptiveLimiter creates a PayloadLimit function following an adaptive payload limiting algorithm

type LimiterState

type LimiterState int

LimiterState represents the LimiterState of the adaptive payload limiter algorithm

const (
	// LimiterStateNormal is the default state and the state when free memory is above the threshold
	LimiterStateNormal LimiterState = iota
	// LimiterStateThreshold is the state when free memory is below the LimiterStateThreshold but above the critical LimiterStateThreshold
	LimiterStateThreshold
	// LimiterStateCritical is the state when free memory is below the LimiterStateCritical threshold
	LimiterStateCritical
)

type LimiterStats

type LimiterStats struct {
	State           LimiterState
	ThresholdFactor int
}

Jump to

Keyboard shortcuts

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