ratelimit

package
v0.0.0-...-653ea31 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemBasedRateLimiter

type MemBasedRateLimiter struct {
	// contains filtered or unexported fields
}

MemBasedRateLimiter is a rate limiter based on memory usage. While the high memory limit is reached, MayWait() blocks and try to release memory. When the low memory limit is reached, MayWait() blocks once and may try to release memory. The memory limits are defined as soft limits.

`memoryRateLimiter` provides a way to dynamically update the rate at which the memory limit is checked. When the soft limit is reached, we would like to wait and release memory but not block too often. `freeOSMemoryRateLimiter` provides a way to dynamically update the rate at which `FreeOSMemory` is called when the soft limit is reached.

func BuildMemBasedRateLimiter

func BuildMemBasedRateLimiter(cfg model.Reader, telemetry telemetry.Component) (*MemBasedRateLimiter, error)

BuildMemBasedRateLimiter builds a new instance of *MemBasedRateLimiter

func NewMemBasedRateLimiter

func NewMemBasedRateLimiter(
	telemetry telemetryInterface,
	memoryUsage memoryUsage,
	lowSoftLimitRate float64,
	highSoftLimitRate float64,
	goGC int,
	memoryRateLimiter geometricRateLimiterConfig,
	freeOSMemoryRateLimiter geometricRateLimiterConfig) (*MemBasedRateLimiter, error)

NewMemBasedRateLimiter creates a new instance of MemBasedRateLimiter.

func (*MemBasedRateLimiter) MayWait

func (m *MemBasedRateLimiter) MayWait() error

MayWait waits and tries to release the memory. See MemBasedRateLimiter for more information.

Jump to

Keyboard shortcuts

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