{"id":24583474,"url":"https://github.com/itmisx/timewheel","last_synced_at":"2025-04-28T10:38:53.394Z","repository":{"id":65950318,"uuid":"602630520","full_name":"itmisx/timewheel","owner":"itmisx","description":"go实现的真正的多层时间轮","archived":false,"fork":false,"pushed_at":"2024-08-10T22:53:19.000Z","size":17,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-30T08:41:32.950Z","etag":null,"topics":[],"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/itmisx.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":"2023-02-16T16:05:57.000Z","updated_at":"2025-02-12T06:39:51.000Z","dependencies_parsed_at":"2024-05-31T03:05:56.596Z","dependency_job_id":null,"html_url":"https://github.com/itmisx/timewheel","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/itmisx%2Ftimewheel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itmisx%2Ftimewheel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itmisx%2Ftimewheel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itmisx%2Ftimewheel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/itmisx","download_url":"https://codeload.github.com/itmisx/timewheel/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251296606,"owners_count":21566640,"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":[],"created_at":"2025-01-24T04:46:42.134Z","updated_at":"2025-04-28T10:38:53.347Z","avatar_url":"https://github.com/itmisx.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# timewheel\n\n\u003e 时间轮，是一种实现延迟功能（定时器）的巧妙算法，在 Netty，Zookeeper，Kafka 等各种框架中，甚至 Linux 内核中都有用到。\n\n#### 🎉 安装\n\n`go get -u -v github.com/itmisx/timewheel`\n\n#### ✅ 使用\n\n```go\n// 结构体方法调用\n{\n\t// 参数1-time.Duration,时间轮精度\n\t// 参数2-int,时间槽数量\n\t// 参数3-func(interface{}),定时器过期回调函数\n\ttw := timewheel.New(time.Second, 60, func(data interface{}){\n           // 参数类型断言\n           param:= data.(type)\n           // 业务逻辑\n           // todo ... \n        })\n\ttw.Start()\n\t// timerID，定时器id，用来删除定时器\n\t// 参数1-string，定时器id，相同的定时器id会覆盖旧的定时器\n\t// 参数2-time.Duration，定时器间隔\n\t// 参数3-interface{}，定时器数据，将传递到回调函数\n\ttw.AddTimer(\"timerID\", time.Second*3, \"data\")\n\ttw.Stop()\n}\n```\n\n#### Benchmark\n\n```\ngoos: darwin\ngoarch: amd64\npkg: 192.168.1.75/go-pkg/timewheel\ncpu: Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz\nBenchmarkTimeWheel-4   \t 1000000\t      1550 ns/op\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitmisx%2Ftimewheel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitmisx%2Ftimewheel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitmisx%2Ftimewheel/lists"}