ratelimit

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

func NewBuilder

func NewBuilder() *Builder

func (*Builder) Build

func (b *Builder) Build() gin.HandlerFunc

func (*Builder) Prefix

func (b *Builder) Prefix(prefix string) *Builder

type Limiter

type Limiter interface {

	/*Limit 就是有没有触发限流, key 就是限流对象
	  如果是对ip限流,那 key 就是ip地址
	  bool 代表是否限流, true 就是要限流
	  error 代表限流器本身是否有错误 */
	Limit(ctx context.Context, key string) (bool, error)
}

func NewRedisSlideWindowLimiter

func NewRedisSlideWindowLimiter(cmd redis.Cmdable,
	interval time.Duration, rate int) Limiter

type RedisSlideWindowLimiter

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

func (*RedisSlideWindowLimiter) Limit

func (r *RedisSlideWindowLimiter) Limit(ctx context.Context, key string) (bool, error)

Directories

Path Synopsis
Code generated by MockGen.
Code generated by MockGen.

Jump to

Keyboard shortcuts

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