limiter

package
v2.167.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingKey = errors.New("limiter: missing key")

ErrMissingKey for limiter.

Module for fx.

Functions

This section is empty.

Types

type Config

type Config struct {
	Kind     string `yaml:"kind,omitempty" json:"kind,omitempty" toml:"kind,omitempty"`
	Interval string `yaml:"interval,omitempty" json:"interval,omitempty" toml:"interval,omitempty"`
	Tokens   uint64 `yaml:"tokens,omitempty" json:"tokens,omitempty" toml:"tokens,omitempty"`
}

Config for limiter.

func (*Config) IsEnabled added in v2.115.0

func (c *Config) IsEnabled() bool

IsEnabled for limiter.

type KeyFunc

type KeyFunc func(context.Context) meta.Value

KeyFunc for the limiter.

type KeyMap added in v2.60.0

type KeyMap map[string]KeyFunc

KeyMap of kind and KeyFunc.

func NewKeyMap added in v2.76.0

func NewKeyMap() KeyMap

NewKeyMap for limiter.

type Limiter

type Limiter struct {
	// contains filtered or unexported fields
}

Limiter holds a store with a key.

func NewLimiter added in v2.73.0

func NewLimiter(lc di.Lifecycle, keys KeyMap, cfg *Config) (*Limiter, error)

NewLimiter limiter.

func (*Limiter) Close

func (l *Limiter) Close(ctx context.Context) error

Close the limiter.

func (*Limiter) Take

func (l *Limiter) Take(ctx context.Context) (bool, string, error)

Take from the store, returns if successful, info and error.

Jump to

Keyboard shortcuts

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