rratelimit

package module
v0.0.0-...-678ac9b Latest Latest
Warning

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

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

README

rratelimit

the ratelimit base of redis

基于redis使用熔断限流

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Creator

type Creator func(client redis.Cmdable, service string,
	interval time.Duration, rate int) Limiter

type FixWindowLimiter

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

func (*FixWindowLimiter) Allow

func (f *FixWindowLimiter) Allow(ctx context.Context) (bool, error)

type Limiter

type Limiter interface {
	Allow(ctx context.Context) (bool, error) // 是否限流
}

func NewFixWindowLimiter

func NewFixWindowLimiter(client redis.Cmdable, service string,
	interval time.Duration, rate int) Limiter

func NewSlideWindowLimiter

func NewSlideWindowLimiter(client redis.Cmdable, service string,
	interval time.Duration, rate int) Limiter

type RateLimit

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

func NewRateLimit

func NewRateLimit(client redis.Cmdable, service string,
	interval time.Duration, rate int, opts ...RateLimitOption) *RateLimit

type RateLimitOption

type RateLimitOption func(*RateLimit) error

func WithSideWindow

func WithSideWindow() RateLimitOption

type SlideWindowLimiter

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

func (*SlideWindowLimiter) Allow

func (f *SlideWindowLimiter) Allow(ctx context.Context) (bool, error)

Directories

Path Synopsis
middleware
gin

Jump to

Keyboard shortcuts

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