leakybucket

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLeakyBucketLimiter

func NewLeakyBucketLimiter(ctx context.Context, client redis.Cmdable, key string, duration time.Duration,
	throughput int, opts ...Option) (ratelimit.Limiter, error)

Types

type LeakyBucketLimiter

type LeakyBucketLimiter struct {
	ratelimit.BaseRateLimiter

	/*
		If the traffic is too large, the limiter will request Redis frequently.
		To avoid this situation, the frequency of accessing Redis will be limited.
	*/
	AntiDDoS bool
	// contains filtered or unexported fields
}

func (*LeakyBucketLimiter) Take

func (r *LeakyBucketLimiter) Take(ctx context.Context) (bool, error)

func (*LeakyBucketLimiter) Wait

func (r *LeakyBucketLimiter) Wait(ctx context.Context) (err error)

wait until take a token or timeout

type Option

type Option func(*LeakyBucketLimiter)

func WithAntiDDos

func WithAntiDDos(antiDDoS bool) Option

Jump to

Keyboard shortcuts

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