etcinit / Speedbump
Licence: mit
A Redis-backed rate limiter in Go
Stars: ✭ 107
Programming Languages
go
31211 projects - #10 most used programming language
Projects that are alternatives of or similar to Speedbump
Gin Boilerplate
The fastest way to deploy a restful api's with Gin Framework with a structured project that defaults to PostgreSQL database and JWT authentication middleware stored in Redis
Stars: ✭ 559 (+422.43%)
Mutual labels: middleware, redis
Redis Ratelimit
A fixed window rate limiter based on Redis
Stars: ✭ 15 (-85.98%)
Mutual labels: redis, rate-limiting
Netdiscovery
NetDiscovery 是一款基于 Vert.x、RxJava 2 等框架实现的通用爬虫框架/中间件。
Stars: ✭ 573 (+435.51%)
Mutual labels: middleware, redis
Meiam.system
.NET 5 / .NET Core 3.1 WebAPI + Vue 2.0 + RBAC 企业级前后端分离权限框架
Stars: ✭ 340 (+217.76%)
Mutual labels: middleware, redis
Strapi Middleware Cache
🔌 A cache middleware for https://strapi.io
Stars: ✭ 146 (+36.45%)
Mutual labels: middleware, redis
Django Channels React Multiplayer
turn based strategy game using django channels, redux, and react hooks
Stars: ✭ 52 (-51.4%)
Mutual labels: middleware, redis
Express Security
nodejs + express security and performance boilerplate.
Stars: ✭ 37 (-65.42%)
Mutual labels: redis, rate-limiting
throttle
Throttling Middleware for Martini
Stars: ✭ 63 (-41.12%)
Mutual labels: middleware, rate-limiting
Redisratelimiter
Redis Based API Access Rate Limiter
Stars: ✭ 80 (-25.23%)
Mutual labels: redis, rate-limiting
Laravel Rate Limited Job Middleware
A job middleware to rate limit jobs
Stars: ✭ 166 (+55.14%)
Mutual labels: middleware, rate-limiting
Permissions2
🔐 Middleware for keeping track of users, login states and permissions
Stars: ✭ 423 (+295.33%)
Mutual labels: middleware, redis
Ginrpc
gin auto binding,grpc, and annotated route,gin 注解路由, grpc,自动参数绑定工具
Stars: ✭ 157 (+46.73%)
Mutual labels: middleware, gin
Learning tools
Go 学习、Go 进阶、Go 实用工具类、Go-kit ,Go-Micro 微服务实践、Go 推送
Stars: ✭ 605 (+465.42%)
Mutual labels: redis, gin
Go Http Metrics
Go modular http middleware to measure HTTP requests independent of metrics backend (with Prometheus and OpenCensus as backend implementations) and http framework/library
Stars: ✭ 128 (+19.63%)
Mutual labels: middleware, gin
Aspnetcoreratelimit
ASP.NET Core rate limiting middleware
Stars: ✭ 2,199 (+1955.14%)
Mutual labels: middleware, rate-limiting
Apicache
Simple API-caching middleware for Express/Node.
Stars: ✭ 957 (+794.39%)
Mutual labels: middleware, redis
Duckygo
一个同时支持Session以及JWT的高性能高可用 Golang Restful API 脚手架 !
Stars: ✭ 57 (-46.73%)
Mutual labels: redis, gin
speedbump
A Redis-backed Rate Limiter for Go
Cool stuff
- Backed by Redis, so it keeps track of requests across a cluster
- Extensible timing functions. Includes defaults for tracking requests per second, minute, and hour
- Works with IPv4, IPv6, or any other unique identifier
- Example middleware included for Gin (See: ginbump) and Negroni (See: negronibump)
Versions
Branch | Go Get Command | Client Version | - |
---|---|---|---|
v2 | go get gopkg.in/etcinit/speedbump.v2 |
gopkg.in/redis.v5 |
Link |
v1, master | go get gopkg.in/etcinit/speedbump.v1 |
gopkg.in/redis.v3 |
Link |
v0 | go get gopkg.in/etcinit/speedbump.v0 |
gopkg.in/redis.v2 |
Link |
Usage
- Get a working Redis server
- Go get:
$ go get github.com/etcinit/speedbump
- Include it in your code
package main
import (
"fmt"
"time"
"github.com/etcinit/speedbump"
"gopkg.in/redis.v5"
)
func main() {
client := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
Password: "",
DB: 0,
})
hasher := speedbump.PerSecondHasher{}
// Here we create a limiter that will only allow 5 requests per second
limiter := speedbump.NewLimiter(client, hasher, 5)
for {
// This example has a hardcoded IP, but you would replace it with the IP
// of a client on a real case.
success, err := limiter.Attempt("127.0.0.1")
if err != nil {
panic(err)
}
if success {
fmt.Println("Successful!")
} else {
fmt.Println("Limited! :(")
}
time.Sleep(time.Millisecond * time.Duration(100))
}
}
- Output:
Successful!
Successful!
Successful!
Successful!
Successful!
Successful!
Limited! :(
Limited! :(
Limited! :(
Limited! :(
Limited! :(
Successful!
Successful!
Successful!
Successful!
Successful!
Successful!
Limited! :(
Limited! :(
Limited! :(
Limited! :(
Successful!
Successful!
...
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].