limiter

package
v2.11.0-dev Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: Apache-2.0, BSD-3-Clause, Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package limiter provides simple rate limiting primitives backed by a synchronous token bucket.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Limiter

type Limiter interface {
	Allow() bool
}

Limiter is used to abstract the rate limiter implementation to only expose the needed function for rate limiting. This is for example useful for testing, allowing us to use a modified rate limiter tuned for testing through the same interface.

func NewTokenTicker

func NewTokenTicker(tokens, maxTokens int64) Limiter

NewTokenTicker is a utility function that allocates a token ticker, initializes necessary fields and returns it

func NewTokenTickerWithInterval

func NewTokenTickerWithInterval(tokens, maxTokens int64, interval time.Duration) Limiter

NewTokenTickerWithInterval is a utility function that allocates a token ticker with a custom interval

Jump to

Keyboard shortcuts

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