{"id":26675613,"url":"https://github.com/linkdata/rate","last_synced_at":"2025-09-01T05:32:22.037Z","repository":{"id":220121615,"uuid":"750814986","full_name":"linkdata/rate","owner":"linkdata","description":"Efficient rate limiter for Go","archived":false,"fork":false,"pushed_at":"2025-08-21T08:26:37.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-21T10:35:09.314Z","etag":null,"topics":["go","golang","nodependencies","rate-limit","rate-limiter","rate-limiting"],"latest_commit_sha":null,"homepage":"","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/linkdata.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,"publiccode":null,"codemeta":null}},"created_at":"2024-01-31T11:26:20.000Z","updated_at":"2025-08-21T08:26:03.000Z","dependencies_parsed_at":"2024-05-20T10:41:17.122Z","dependency_job_id":"a0680392-029a-4e86-84b1-375b88957454","html_url":"https://github.com/linkdata/rate","commit_stats":null,"previous_names":["linkdata/rate"],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/linkdata/rate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkdata%2Frate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkdata%2Frate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkdata%2Frate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkdata%2Frate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linkdata","download_url":"https://codeload.github.com/linkdata/rate/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkdata%2Frate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273077227,"owners_count":25041358,"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-01T02:00:09.058Z","response_time":120,"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":["go","golang","nodependencies","rate-limit","rate-limiter","rate-limiting"],"created_at":"2025-03-26T03:18:53.335Z","updated_at":"2025-09-01T05:32:21.980Z","avatar_url":"https://github.com/linkdata.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![build](https://github.com/linkdata/rate/actions/workflows/go.yml/badge.svg)](https://github.com/linkdata/rate/actions/workflows/go.yml)\n[![coverage](https://github.com/linkdata/rate/blob/coverage/main/badge.svg)](https://htmlpreview.github.io/?https://github.com/linkdata/rate/blob/coverage/main/report.html)\n[![goreport](https://goreportcard.com/badge/github.com/linkdata/rate)](https://goreportcard.com/report/github.com/linkdata/rate)\n[![Docs](https://godoc.org/github.com/linkdata/rate?status.svg)](https://godoc.org/github.com/linkdata/rate)\n\n## An efficient rate limiter for Go\n\nBecause too much of the CPU consumed was `golang.org/x/time/rate.Limiter.Wait()` calling `time.Now()`.\n\n### Differences from `golang.org/x/time/rate` and `time.Ticker`\n\nThis package uses ticks-per-second rather than `time.Duration`, and is suitable for high-tickrate applications.\nIt allows you to change the rate by simply atomically changing an `int32`. It has no practical limitation on the upper rate.\nIf you need a slower rate than once per second, you're better off using `time.Ticker`.\n\n### Sample usage\n\nOne of the more common non-trivial usages of rate limiting is restricting some underlying operation(s)\nbeing utilized by more complex worker goroutines. This package supports those with `Ticker.Worker()`.\n\nAssume we have a channel `taskCh` where we read tasks to process, and then\nwant spawn worker goroutines that handle them. We want to spawn enough of them\nto stay as close to the max rate as possible without starting *too* many of them.\n\n```go\nfor task := range taskCh {\n  // make sure to not alias variables you use in the lambda\n  // in case you use Go versions prior to 1.22.\n  task := task\n  if !ticker.Worker(func() { workerFn(ticker, task) }) {\n    // if ticker.Worker() fails to start the worker, it means the Ticker is closed.\n    break\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinkdata%2Frate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinkdata%2Frate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinkdata%2Frate/lists"}