simpleratelimit

package
v0.0.0-...-44221c2 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2018 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RateLimiter

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

RateLimiter 限速器

func New

func New(rate int, per time.Duration) *RateLimiter

New 创建RateLimiter实例

func (*RateLimiter) Limit

func (rl *RateLimiter) Limit() bool

Limit 判断是否超过限制

func (*RateLimiter) Undo

func (rl *RateLimiter) Undo()

Undo 重置上一次调用Limit(),返回没有使用过的限额

func (*RateLimiter) UpdateRate

func (rl *RateLimiter) UpdateRate(rate int)

UpdateRate 更新速率值

Jump to

Keyboard shortcuts

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