go-rate alternatives and similar packages
Based on the "Utilities" category.
Alternatively, view go-rate alternatives based on common mentions on social networks and blogs.
-
项目文档
基于vite+vue3+gin搭建的开发基础平台(支持TS,JS混用),集成jwt鉴权,权限管理,动态路由,显隐可控组件,分页封装,多点登录拦截,资源权限,上传下载,代码生成器,表单生成器等开发必备功能。 -
excelize
Go language library for reading and writing Microsoft Excel™ (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets -
xlsx
(No longer maintained!) Go (golang) library for reading and writing XLSX files. -
godotenv
A Go port of Ruby's dotenv library (Loads environment variables from `.env`.) -
hystrix-go
Netflix's Hystrix latency and fault tolerance library, for Go -
go-funk
A modern Go utility library which provides helpers (map, find, contains, filter, ...) -
gorequest
GoRequest -- Simplified HTTP client ( inspired by nodejs SuperAgent ) -
goreporter
A Golang tool that does static analysis, unit testing, code review and generate code quality report. -
Kopia
Cross-platform backup tool for Windows, macOS & Linux with fast, incremental backups, client-side end-to-end encryption, compression and data deduplication. CLI and GUI included. -
gojson
Automatically generate Go (golang) struct definitions from example JSON -
lancet
A comprehensive, efficient, and reusable util function library of go. -
spinner
Go (golang) package with 90 configurable terminal spinner/progress indicators. -
create-go-app
✨ Create a new production-ready project with backend, frontend and deploy automation by running one CLI command! -
filetype
Fast, dependency-free Go package to infer binary file types based on the magic numbers header signature -
boilr
:zap: boilerplate template manager that generates files or directories from template repositories -
mole
CLI application to create ssh tunnels focused on resiliency and user experience. -
EaseProbe
A simple, standalone, and lightweight tool that can do health/status checking, written in Go. -
beaver
💨 A real time messaging system to build a scalable in-app notifications, multiplayer games, chat apps in web and mobile apps. -
go-underscore
Helpfully Functional Go - A useful collection of Go utilities. Designed for programmer happiness. -
JobRunner
Framework for performing work asynchronously, outside of the request flow -
mimetype
A fast Golang library for media type and file extension detection, based on magic numbers -
git-time-metric
Simple, seamless, lightweight time tracking for Git
Build time-series-based applications quickly and at scale.
Do you think we are missing an alternative of go-rate or a related project?
Popular Comparisons
README
go-rate
go-rate is a rate limiter designed for a range of use cases, including server side spam protection and preventing saturation of APIs you consume.
It is used in production at LangTrend to adhere to the GitHub API rate limits.
Usage
Import github.com/beefsack/go-rate
and create a new rate limiter with
the rate.New(limit int, interval time.Duration)
function.
The rate limiter provides a Wait()
and a Try() (bool, time.Duration)
method
for both blocking and non-blocking functionality respectively.
API documentation available at godoc.org.
Examples
Blocking rate limiting
This example demonstrates limiting the output rate to 3 times per second.
package main
import (
"fmt"
"time"
"github.com/beefsack/go-rate"
)
func main() {
rl := rate.New(3, time.Second) // 3 times per second
begin := time.Now()
for i := 1; i <= 10; i++ {
rl.Wait()
fmt.Printf("%d started at %s\n", i, time.Now().Sub(begin))
}
// Output:
// 1 started at 12.584us
// 2 started at 40.13us
// 3 started at 44.92us
// 4 started at 1.000125362s
// 5 started at 1.000143066s
// 6 started at 1.000144707s
// 7 started at 2.000224641s
// 8 started at 2.000240751s
// 9 started at 2.00024244s
// 10 started at 3.000314332s
}
Blocking rate limiting with multiple limiters
This example demonstrates combining rate limiters, one limiting at once per second, the other limiting at 2 times per 3 seconds.
package main
import (
"fmt"
"time"
"github.com/beefsack/go-rate"
)
func main() {
begin := time.Now()
rl1 := rate.New(1, time.Second) // Once per second
rl2 := rate.New(2, time.Second*3) // 2 times per 3 seconds
for i := 1; i <= 10; i++ {
rl1.Wait()
rl2.Wait()
fmt.Printf("%d started at %s\n", i, time.Now().Sub(begin))
}
// Output:
// 1 started at 11.197us
// 2 started at 1.00011941s
// 3 started at 3.000105858s
// 4 started at 4.000210639s
// 5 started at 6.000189578s
// 6 started at 7.000289992s
// 7 started at 9.000289942s
// 8 started at 10.00038286s
// 9 started at 12.000386821s
// 10 started at 13.000465465s
}
Non-blocking rate limiting
This example demonstrates non-blocking rate limiting, such as would be used to limit spam in a chat client.
package main
import (
"fmt"
"time"
"github.com/beefsack/go-rate"
)
var rl = rate.New(3, time.Second) // 3 times per second
func say(message string) {
if ok, remaining := rl.Try(); ok {
fmt.Printf("You said: %s\n", message)
} else {
fmt.Printf("Spam filter triggered, please wait %s\n", remaining)
}
}
func main() {
for i := 1; i <= 5; i++ {
say(fmt.Sprintf("Message %d", i))
}
time.Sleep(time.Second / 2)
say("I waited half a second, is that enough?")
time.Sleep(time.Second / 2)
say("Okay, I waited a second.")
// Output:
// You said: Message 1
// You said: Message 2
// You said: Message 3
// Spam filter triggered, please wait 999.980816ms
// Spam filter triggered, please wait 999.976704ms
// Spam filter triggered, please wait 499.844795ms
// You said: Okay, I waited a second.
}