ratelimit

package
v0.0.0-...-2feb83d Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 10 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 config.Reader) (*MemBasedRateLimiter, error)

BuildMemBasedRateLimiter builds a new instance of *MemBasedRateLimiter

func NewMemBasedRateLimiter

func NewMemBasedRateLimiter(
	telemetry telemetry,
	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