limiter

package
v0.0.0-...-780cc0d Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

README

###限流器

golang.org/x/time/rate 官方限流器 go.uber.org/ratelimit uber出的限流器

####文档: https://blog.csdn.net/tzh_linux/article/details/106141271

####说明: ratelimit.New(c.Rate)表示限制每秒执行的次数

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Rate int `mapstructure:"rate"`
}

type Limiter

type Limiter struct {
	Config
	Limiter ratelimit.Limiter
}

func NewLimiter

func NewLimiter(c Config) *Limiter

NewLimiter 限流器

func (Limiter) Endpoint

func (l Limiter) Endpoint(next endpoint.Endpoint) endpoint.Endpoint

func (Limiter) Limit

func (l Limiter) Limit()

func (Limiter) Middleware

func (l Limiter) Middleware() endpoint.Middleware

Jump to

Keyboard shortcuts

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