rate_limit

package module
v0.0.0-...-607d407 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

README

rate_limit

基于各种中间件实现的流控

Documentation

Overview

Package rate_limit ...

Description : rate_limit ...

Author : go_developer@163.com<白茶清欢>

Date : 2024-06-24 15:04

Package rate_limit ...

Description : rate_limit ...

Author : go_developer@163.com<白茶清欢>

Date : 2024-06-20 20:40

Package rate_limit ...

Description : rate_limit ...

Author : go_developer@163.com<白茶清欢>

Date : 2023-03-09 11:31

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultClient = &Default{}
)
View Source
var (
	MemoryClient = &Memory{
		lock:         &sync.RWMutex{},
		limiterTable: make(map[string]*rate.Limiter),
	}
)
View Source
var (
	RedisClient = &Redis{}
)

Functions

This section is empty.

Types

type Default

type Default struct {
}

func (Default) AllowN

func (d Default) AllowN(ctx context.Context, limitCfg *define.LimitConfig, tokenCnt int) (bool, error)

func (Default) Reset

func (d Default) Reset(ctx context.Context, limitCfg *define.LimitConfig) error

type Memory

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

Memory ...

Author : go_developer@163.com<白茶清欢>

Date : 20:40 2024/6/20

func (*Memory) AllowN

func (m *Memory) AllowN(ctx context.Context, limitCfg *define.LimitConfig, tokenCnt int) (bool, error)

func (*Memory) Reset

func (m *Memory) Reset(ctx context.Context, limitCfg *define.LimitConfig) error

type Redis

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

Redis ...

Author : go_developer@163.com<白茶清欢>

Date : 11:44 2024/6/20

func (*Redis) AllowN

func (r *Redis) AllowN(ctx context.Context, limitCfg *define.LimitConfig, tokenCnt int) (bool, error)

func (*Redis) Reset

func (r *Redis) Reset(ctx context.Context, limitCfg *define.LimitConfig) error

func (*Redis) SetRedisClient

func (r *Redis) SetRedisClient(client *redisInstance.Client)

Directories

Path Synopsis
Package abstract ...
Package abstract ...
Package define ...
Package define ...

Jump to

Keyboard shortcuts

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