{"id":30030049,"url":"https://github.com/asticode/go-ratelimiter","last_synced_at":"2025-09-18T16:43:09.450Z","repository":{"id":57518902,"uuid":"48362833","full_name":"asticode/go-ratelimiter","owner":"asticode","description":"Deprecated","archived":false,"fork":false,"pushed_at":"2016-06-14T06:53:13.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-06T18:57:46.298Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/asticode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-21T09:26:55.000Z","updated_at":"2017-04-19T09:44:13.000Z","dependencies_parsed_at":"2022-09-26T18:00:46.410Z","dependency_job_id":null,"html_url":"https://github.com/asticode/go-ratelimiter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/asticode/go-ratelimiter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asticode%2Fgo-ratelimiter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asticode%2Fgo-ratelimiter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asticode%2Fgo-ratelimiter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asticode%2Fgo-ratelimiter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asticode","download_url":"https://codeload.github.com/asticode/go-ratelimiter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asticode%2Fgo-ratelimiter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275797771,"owners_count":25530253,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-18T02:00:09.552Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-06T18:50:48.981Z","updated_at":"2025-09-18T16:43:09.443Z","avatar_url":"https://github.com/asticode.png","language":"Go","readme":"# About\n\n[![godoc](http://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/github.com/asticode/go-ratelimiter/ratelimiter)\n\n`go-ratelimiter` is a multi-buckets rate limiter for the GO programming language (http://golang.org).\n\n# Install `go-ratelimiter`\n\nRun the following command:\n\n    $ go get github.com/asticode/go-ratelimiter/ratelimiter\n    \n# Example\n    \n    import (\n        basememcache \"github.com/bradfitz/gomemcache/memcache\"\n        \"github.com/asticode/go-memcache/memcache\"\n        \"github.com/asticode/go-ratelimiter/ratelimiter\"\n    )\n    \n    // Create the cache\n    // In this example I'll use asticode/go-memcache but you can use another cache solution\n    m := memcache.NewMemcache(\"myhost\", \"myprefix_\", 10)\n    \n    // Create the rate limiter\n    r := NewRateLimiter(\n        m,\n        basememcache.errCacheMiss,\n    )\n    \n    // Add a limit of 2 requests for a duration of 5 seconds\n    r.AddBucket(5, 2)\n    \n    // Add a limit of 10 request for a duration of 5 minutes\n    r.AddBucket(5 * 60, 10)\n    \n    // Get key to validate\n    key := \"key_test\"\n    \n    // Validate twice won't return an error as 2 requests are permitted for a timespan of 5 seconds\n    e := r.Validate(key)\n    e = r.Validate(key)\n    \n    // But this time this call will return an errLimitReached\n    e = r.Validate(key)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasticode%2Fgo-ratelimiter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasticode%2Fgo-ratelimiter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasticode%2Fgo-ratelimiter/lists"}