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 ¶
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 ¶
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
}
Click to show internal directories.
Click to hide internal directories.