【文件属性】:
文件名称:rate:分布式系统的Golang限速器
文件大小:6KB
文件格式:ZIP
更新时间:2021-03-11 22:44:46
系统开源
分布式系统的Golang限速器
执行
根据,使用Redis Server和Lua Script基于实现速率限制器。
安装
go get " github.com/wallstreetcn/rate "
用法
import (
rate "github.com/wallstreetcn/rate/redis"
)
// initialize redis.
rate. SetRedis ( & rate. ConfigRedis {
Host : "127.0.0.1" ,
Port : 6379 ,
Auth : "" ,
}
// setup a 1 ops/s rate limiter.
limiter := rate . NewLimiter ( Every ( time . Second ), 1 , "a-sample-operation" )
if
【文件预览】:
rate-master
----.travis.yml(200B)
----LICENSE(1KB)
----.gitignore(275B)
----redis()
--------rate_test.go(2KB)
--------rate.go(4KB)
--------client.go(675B)
----README.md(1KB)