{"id":20810550,"url":"https://github.com/huttotw/warm-up","last_synced_at":"2025-08-30T10:41:26.455Z","repository":{"id":75942035,"uuid":"175865377","full_name":"huttotw/warm-up","owner":"huttotw","description":"A implementation of a rate limiter that will allow the rate to increase over the course of time according to some function.","archived":false,"fork":false,"pushed_at":"2019-03-18T15:08:36.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-14T13:52:59.782Z","etag":null,"topics":["channels","golang","rate","time","up","warm"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/huttotw.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":"2019-03-15T17:36:29.000Z","updated_at":"2022-11-14T20:15:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"b36ebe70-1c90-43a2-b989-b936c6bd8709","html_url":"https://github.com/huttotw/warm-up","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/huttotw/warm-up","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huttotw%2Fwarm-up","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huttotw%2Fwarm-up/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huttotw%2Fwarm-up/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huttotw%2Fwarm-up/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/huttotw","download_url":"https://codeload.github.com/huttotw/warm-up/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huttotw%2Fwarm-up/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272839668,"owners_count":25001862,"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-08-30T02:00:09.474Z","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":["channels","golang","rate","time","up","warm"],"created_at":"2024-11-17T20:25:58.264Z","updated_at":"2025-08-30T10:41:26.379Z","avatar_url":"https://github.com/huttotw.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# warm-up\n\nWarm up is a pseudo implementation of `golang.org/x/time/rate` with the biggest difference being that you can supply a\ncustom function with which to calculate the rate at every token. Please see the [Golang documentation](https://godoc.org/golang.org/x/time/rate) for details on the\nterminology used here, especially _Limiter_, _tokens_, and _bucket_.\n\n### Use cases:\n\n- Sending lots of requests to a system, but you want to give the system a chance to auto-scale.\n- Warming up a load balancer to be ready to handle a lot of requests.\n- Gradually increasing load to a system.\n\n## Example\n\n```go\nfunc main() {\n\tfmt.Println(\"starting...\")\n\n\t// Define our custom function\n\tf := func(x float64) float64 {\n\t\treturn math.Pow(x/10, 2)\n\t}\n\n\t// Create a new limiter that will increase in throughput according to (x/10)^2,\n\t// with a burst up to 0 tokens.\n\tl := warmup.NewLimiter(f, 0)\n\tdefer l.Stop()\n\n\ti := 0\n\tfor {\n\t\tctx := context.Background()\n\t\tl.WaitN(ctx, 1)\n\t\tfmt.Println(\"i\", i)\n\t\ti++\n\t}\n}\n```\n\nThis example will print out at each iteration, slowly increasing over time.\n\n## To Do\n\n- [ ] Implement `AllowN`\n- [ ] Implement `ReserveN`\n- [ ] Handle cancellations and deadlines properly.\n\n## License\n\nCopyright © 2019 Trevor Hutto\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at:\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuttotw%2Fwarm-up","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhuttotw%2Fwarm-up","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuttotw%2Fwarm-up/lists"}