limiter

package
v1.0.4-preview.2 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: AGPL-3.0 Imports: 6 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Capacity  int64
	Rate      int64
	Requested int64
}

Config 配置选项模式

type Option

type Option func(*Config)

func WithCapacity

func WithCapacity(c int64) Option

func WithRate

func WithRate(r int64) Option

func WithRequested

func WithRequested(n int64) Option

type RedisLimiter

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

func New

func New(ctx context.Context, r *redis.Client) *RedisLimiter

func (*RedisLimiter) Allow

func (rl *RedisLimiter) Allow(ctx context.Context, key string, opts ...Option) (bool, error)

Jump to

Keyboard shortcuts

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