{"id":13786666,"url":"https://github.com/yudppp/throttle","last_synced_at":"2026-01-26T09:36:17.720Z","repository":{"id":47546165,"uuid":"217552094","full_name":"yudppp/throttle","owner":"yudppp","description":"lodash throttle like Go library","archived":false,"fork":false,"pushed_at":"2021-08-24T15:15:43.000Z","size":20,"stargazers_count":40,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-15T06:45:22.407Z","etag":null,"topics":[],"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/yudppp.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":"2019-10-25T14:30:38.000Z","updated_at":"2025-02-14T09:02:14.000Z","dependencies_parsed_at":"2022-08-24T12:31:12.708Z","dependency_job_id":null,"html_url":"https://github.com/yudppp/throttle","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/yudppp/throttle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yudppp%2Fthrottle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yudppp%2Fthrottle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yudppp%2Fthrottle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yudppp%2Fthrottle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yudppp","download_url":"https://codeload.github.com/yudppp/throttle/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yudppp%2Fthrottle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28772914,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T08:38:24.014Z","status":"ssl_error","status_checked_at":"2026-01-26T08:38:22.080Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":"2024-08-03T19:01:27.608Z","updated_at":"2026-01-26T09:36:17.704Z","avatar_url":"https://github.com/yudppp.png","language":"Go","funding_links":[],"categories":["公用事业公司","Utilities","Utility"],"sub_categories":["实用程序/Miscellaneous","Utility/Miscellaneous","Fail injection","HTTP Clients"],"readme":"# Throttle\n\n![test workflow](https://github.com/yudppp/throttle/actions/workflows/test.yml/badge.svg)\n[![Go Report Card](https://goreportcard.com/badge/github.com/yudppp/throttle)](https://goreportcard.com/report/github.com/yudppp/throttle)\n[![Coverage Status](https://coveralls.io/repos/github/yudppp/throttle/badge.svg?branch=master)](https://coveralls.io/github/yudppp/throttle?branch=master)\n\nThrottle is an object that will perform exactly one action per duration.\nDo call the function f if a specified duration has passed since the last function f was called for this instance of Throttle.\n\n\u003cimg width=\"555\" alt=\"Group 38 (1)\" src=\"https://user-images.githubusercontent.com/4619802/130463248-b27fa321-24ce-47d1-9f9c-5f8b730d73c0.png\"\u003e\n\n## Examples\n\n### single thread\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/yudppp/throttle\"\n)\n\nfunc main() {\n\tthrottler := throttle.New(time.Second)\n\tthrottler.Do(func() {\n\t\tfmt.Println(\"first call\")\n\t})\n\tthrottler.Do(func() {\n\t\t// this function called never.\n\t\tfmt.Println(\"second call\")\n\t})\n\ttime.Sleep(time.Second)\n\tthrottler.Do(func() {\n\t\tfmt.Println(\"third call\")\n\t})\n\ttime.Sleep(time.Second)\n}\n```\n\n```\n$ go run -race main.go\nfirst call\nthird call\n```\n\n### multiple threads\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/yudppp/throttle\"\n)\n\nfunc main() {\n\tthrottler := throttle.New(time.Second)\n\tvar wg sync.WaitGroup\n\tfor i := 0; i \u003c 64; i++ {\n\t\twg.Add(1)\n\t\tgo func(i int) {\n\t\t\tthrottler.Do(func() {\n\t\t\t\tfmt.Println(\"called\")\n\t\t\t})\n\t\t\twg.Done()\n\t\t}(i)\n\t}\n\twg.Wait()\n}\n```\n\n```\n$ go run -race main.go\ncalled\n```\n\n## License\n\n[The MIT License (MIT)](https://github.com/yudppp/throttle/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyudppp%2Fthrottle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyudppp%2Fthrottle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyudppp%2Fthrottle/lists"}