limiter

package
v0.28.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package limiter provides a cached traffic limiter that wraps a TrafficLimiter with in-memory caching to reduce calls to the underlying limiter (e.g., plugin-based limiters).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCachedTrafficLimiter

func NewCachedTrafficLimiter(limiter traffic.TrafficLimiter, opts ...Option) traffic.TrafficLimiter

NewCachedTrafficLimiter wraps a TrafficLimiter with an in-memory cache. Cached limiters are refreshed after the configured refresh interval. Returns nil if the inner limiter is nil.

Types

type Option

type Option func(*options)

Option configures a cachedTrafficLimiter.

func CleanupIntervalOption

func CleanupIntervalOption(interval time.Duration) Option

CleanupIntervalOption sets the interval for cleaning up expired cache entries. The minimum value is 1 second.

func RefreshIntervalOption

func RefreshIntervalOption(interval time.Duration) Option

RefreshIntervalOption sets the cache refresh interval. Cached limiters are refreshed after this duration. The minimum value is 1 second.

func ScopeOption

func ScopeOption(scope string) Option

ScopeOption filters cached limiters by scope. When set, only requests with a matching scope return a limiter; non-matching scopes return nil.

Jump to

Keyboard shortcuts

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