https://github.com/0verread/goralim Skip to content Toggle navigation Sign in * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code Explore + All features + Documentation + GitHub Skills + Blog * Solutions For + Enterprise + Teams + Startups + Education By Solution + CI/CD & Automation + DevOps + DevSecOps Resources + Learning Pathways + White papers, Ebooks, Webinars + Customer Stories + Partners * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} 0verread / goralim Public * Notifications * Fork 2 * Star 84 * A rate limiting package for Go to handle distributed workloads License MIT license 84 stars 2 forks Branches Tags Activity Star Notifications * Code * Issues 0 * Pull requests 2 * Actions * Projects 0 * Security * Insights Additional navigation options * Code * Issues * Pull requests * Actions * Projects * Security * Insights 0verread/goralim This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. main BranchesTags Go to file Code Folders and files Name Name Last commit message Last commit date Latest commit History 7 Commits examples examples images images .gitignore .gitignore LICENSE LICENSE README.md README.md go.mod go.mod go.sum go.sum goralim.go goralim.go middleware.go middleware.go redis.go redis.go View all files Repository files navigation * README * MIT license banner Goralim goralim is a Golang package that provides a rate limiter based on Token bucket algorithm. It is capabale to handle distributed workload with its redis database support. It has HTTP server middleware support (as of now). this is a beta version now and under active development. For production use, fork it and made changes based on your need. Install go get "github.com/0verread/goralim" -m Usage import ( goralim "github.com/0verread/goralim" ) // Redis initialization config := goralim.RedisConfig { HOST: "127.0.0.1", PORT: 6379, // password PASS: "", } redisStore := goralim.NewRedisClient(config) // setup rate limiter for a key (key can be userId/client) // 10 is bucket size, 5 is bucket refill rate per second tb := goralim.NewTokenBucket("key123", redisStore, 10, 5) // create HTTP server and setup a goralim middleware to put a rate limiter handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, "Hey There this is a Request") }) rateLimitedHandler := goralim.RateLimiter(tb, handler) http.ListenAndServe(":8080", rateLimitedHandler) License Under MIT license About A rate limiting package for Go to handle distributed workloads Topics redis golang distributed-systems rate-limiting rate-limiter Resources Readme License MIT license Activity Stars 84 stars Watchers 1 watching Forks 2 forks Report repository Releases 1 tags Languages * Go 100.0% Footer (c) 2024 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact * Manage cookies * Do not share my personal information You can't perform that action at this time.