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 ¶
CleanupIntervalOption sets the interval for cleaning up expired cache entries. The minimum value is 1 second.
func RefreshIntervalOption ¶
RefreshIntervalOption sets the cache refresh interval. Cached limiters are refreshed after this duration. The minimum value is 1 second.
func ScopeOption ¶
ScopeOption filters cached limiters by scope. When set, only requests with a matching scope return a limiter; non-matching scopes return nil.