Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OptionsCoalescing ¶
type OptionsCoalescing struct { // InitialDelay is the initial delay for the rate limiter. The rate limiter // will not delay events less than the initial delay. // Defaults to 500ms. InitialDelay *time.Duration // MaxDelay is the maximum delay for the rate limiter. The rate limiter will // not delay events longer than the max delay. // Defaults to 5s. MaxDelay *time.Duration // MaxPendingEvents is the maximum number of events that can pending on a // rate limiter, before it fires an event anyway. Useful to prevent a rate // limiter never firing events in a high throughput scenario. // Defaults to unlimited. MaxPendingEvents *int }
OptionsCoalescing configures a Coalescing RateLimiter.
type RateLimiter ¶
type RateLimiter interface { // Run starts the rate limiter. The given channel will have events sent to // it, according to the rate limited parameters. Run(ctx context.Context, eventCh chan<- struct{}) error // Add adds a new event to the rate limiter. Add() // Close closes the rate limiter and waits for all resources to be released. Close() }
RateLimiter is the interface for rate limiting events.
func NewCoalescing ¶
func NewCoalescing(opts OptionsCoalescing) (RateLimiter, error)
Click to show internal directories.
Click to hide internal directories.