{"id":15272412,"url":"https://github.com/etcinit/speedbump","last_synced_at":"2025-04-12T09:30:45.783Z","repository":{"id":30630280,"uuid":"34185746","full_name":"etcinit/speedbump","owner":"etcinit","description":"A Redis-backed rate limiter in Go","archived":false,"fork":false,"pushed_at":"2022-03-28T19:17:09.000Z","size":25,"stargazers_count":116,"open_issues_count":3,"forks_count":10,"subscribers_count":7,"default_branch":"v2","last_synced_at":"2024-10-31T11:51:32.678Z","etag":null,"topics":["gin","go","middleware","negroni","rate-limiting","redis","throttle"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/etcinit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-04-18T22:47:36.000Z","updated_at":"2024-07-27T06:24:53.000Z","dependencies_parsed_at":"2022-08-28T11:51:15.447Z","dependency_job_id":null,"html_url":"https://github.com/etcinit/speedbump","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etcinit%2Fspeedbump","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etcinit%2Fspeedbump/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etcinit%2Fspeedbump/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etcinit%2Fspeedbump/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/etcinit","download_url":"https://codeload.github.com/etcinit/speedbump/tar.gz/refs/heads/v2","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223510333,"owners_count":17157306,"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":["gin","go","middleware","negroni","rate-limiting","redis","throttle"],"created_at":"2024-09-30T09:06:34.631Z","updated_at":"2024-11-07T12:03:31.671Z","avatar_url":"https://github.com/etcinit.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# [speedbump](https://github.com/etcinit/speedbump) [![GoDoc](https://godoc.org/github.com/etcinit/speedbump?status.svg)](http://godoc.org/github.com/etcinit/speedbump)\n\nA Redis-backed Rate Limiter for Go\n\n[![wercker status](https://app.wercker.com/status/9832225d9e89d9702d4ce7ca4e8e4285/m/master \"wercker status\")](https://app.wercker.com/project/bykey/9832225d9e89d9702d4ce7ca4e8e4285)\n\n## Cool stuff\n\n- Backed by Redis, so it keeps track of requests across a cluster\n- Extensible timing functions. Includes defaults for tracking requests per\nsecond, minute, and hour\n- Works with IPv4, IPv6, or any other unique identifier\n- Example middleware included for [Gin](https://github.com/gin-gonic/gin) (See: [ginbump](https://github.com/etcinit/speedbump/blob/master/ginbump)) and\n[Negroni](https://github.com/codegangsta/negroni) (See:\n[negronibump](https://github.com/etcinit/speedbump/blob/master/negronibump))\n\n## Versions\n\n|Branch|Go Get Command|Client Version|-|\n|---|---|---|---|\n|**v2**|`go get gopkg.in/etcinit/speedbump.v2`|`gopkg.in/redis.v5`|[Link](https://gopkg.in/etcinit/speedbump.v2)|\n|**v1**, **master**|`go get gopkg.in/etcinit/speedbump.v1`|`gopkg.in/redis.v3`|[Link](https://gopkg.in/etcinit/speedbump.v1)|\n|**v0**|`go get gopkg.in/etcinit/speedbump.v0`|`gopkg.in/redis.v2`|[Link](https://gopkg.in/etcinit/speedbump.v0)|\n\n## Usage\n\n- Get a working Redis server\n- Go get:\n\n```sh\n$ go get github.com/etcinit/speedbump\n```\n\n- Include it in your code\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/etcinit/speedbump\"\n\t\"gopkg.in/redis.v5\"\n)\n\nfunc main() {\n\tclient := redis.NewClient(\u0026redis.Options{\n\t\tAddr:     \"localhost:6379\",\n\t\tPassword: \"\",\n\t\tDB:       0,\n\t})\n\thasher := speedbump.PerSecondHasher{}\n\n\t// Here we create a limiter that will only allow 5 requests per second\n\tlimiter := speedbump.NewLimiter(client, hasher, 5)\n\n\tfor {\n\t\t// This example has a hardcoded IP, but you would replace it with the IP\n\t\t// of a client on a real case.\n\t\tsuccess, err := limiter.Attempt(\"127.0.0.1\")\n\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\tif success {\n\t\t\tfmt.Println(\"Successful!\")\n\t\t} else {\n\t\t\tfmt.Println(\"Limited! :(\")\n\t\t}\n\n\t\ttime.Sleep(time.Millisecond * time.Duration(100))\n\t}\n}\n```\n\n- Output:\n\n```\nSuccessful!\nSuccessful!\nSuccessful!\nSuccessful!\nSuccessful!\nSuccessful!\nLimited! :(\nLimited! :(\nLimited! :(\nLimited! :(\nLimited! :(\nSuccessful!\nSuccessful!\nSuccessful!\nSuccessful!\nSuccessful!\nSuccessful!\nLimited! :(\nLimited! :(\nLimited! :(\nLimited! :(\nSuccessful!\nSuccessful!\n...\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fetcinit%2Fspeedbump","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fetcinit%2Fspeedbump","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fetcinit%2Fspeedbump/lists"}