{"id":18700162,"url":"https://github.com/shareed2k/go_limiter","last_synced_at":"2025-04-12T08:20:29.553Z","repository":{"id":57519426,"uuid":"249378361","full_name":"Shareed2k/go_limiter","owner":"Shareed2k","description":"Rate limiting with few algorithms","archived":false,"fork":false,"pushed_at":"2024-02-29T13:10:48.000Z","size":20,"stargazers_count":20,"open_issues_count":1,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T03:23:38.451Z","etag":null,"topics":["gcra","go-redis","golang","http","leaky-bucket","middleware","rate-limiting","redis","sliding-window"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Shareed2k.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,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-03-23T08:46:22.000Z","updated_at":"2024-10-05T18:08:16.000Z","dependencies_parsed_at":"2024-02-29T14:42:03.567Z","dependency_job_id":null,"html_url":"https://github.com/Shareed2k/go_limiter","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shareed2k%2Fgo_limiter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shareed2k%2Fgo_limiter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shareed2k%2Fgo_limiter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shareed2k%2Fgo_limiter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Shareed2k","download_url":"https://codeload.github.com/Shareed2k/go_limiter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248537261,"owners_count":21120723,"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","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":["gcra","go-redis","golang","http","leaky-bucket","middleware","rate-limiting","redis","sliding-window"],"created_at":"2024-11-07T11:36:02.413Z","updated_at":"2025-04-12T08:20:29.534Z","avatar_url":"https://github.com/Shareed2k.png","language":"Go","readme":"# Rate limiting with few algorithms (Sliding Window, Leaky Bucket)\n\n[![Build Status](https://travis-ci.org/Shareed2k/go_limiter.svg?branch=master)](github.com/shareed2k/go_limiter)\n\nThis package is based on [go-redis/redis_rate](https://github.com/go-redis/redis_rate) and implements GCRA (aka leaky bucket) for rate limiting based on Redis. The code requires Redis version 3.2 or newer since it relies on replicate_commands feature.\n\n## Installation\n\ngo_limiter requires a Go version with [Modules](https://github.com/golang/go/wiki/Modules) support and uses import versioning. So please make sure to initialize a Go module before installing go_limiter:\n\n```shell\ngo get github.com/shareed2k/go_limiter\n```\n\nImport:\n```go\nimport \"github.com/shareed2k/go_limiter\"\n```\n\n## Examplle\n```go\nimport (\n\t\"log\"\n\t\"time\"\n\n\t\"github.com/redis/go-redis/v9\"\n\n\t\"github.com/shareed2k/go_limiter\"\n)\n\nfunc main() {\n\toption, err := redis.ParseURL(\"redis://127.0.0.1:6379/0\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tclient := redis.NewClient(option)\n\t_ = client.FlushDB().Err()\n\n\tlimiter := go_limiter.NewLimiter(client)\n\tres, err := limiter.Allow(\"api_gateway_cache:klu4ik\", \u0026go_limiter.Limit{\n\t\t// or you can use go_limiter.SlidingWindowAlgorithm\n\t\tAlgorithm: go_limiter.GCRAAlgorithm,\n\t\tRate:      10,\n\t\tPeriod:    2 * time.Minute,\n\t\tBurst:     10,\n\t})\n\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tlog.Println(\"===\u003e \", res.Allowed, res.Remaining)\n\t// Output: true 1\n}\n \n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshareed2k%2Fgo_limiter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshareed2k%2Fgo_limiter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshareed2k%2Fgo_limiter/lists"}