https://github.com/hyperjiang/timewheel
Time wheel in golang.
https://github.com/hyperjiang/timewheel
Last synced: about 1 year ago
JSON representation
Time wheel in golang.
- Host: GitHub
- URL: https://github.com/hyperjiang/timewheel
- Owner: hyperjiang
- License: mit
- Created: 2025-05-21T06:33:36.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-22T07:37:11.000Z (about 1 year ago)
- Last Synced: 2025-06-06T18:53:13.573Z (about 1 year ago)
- Language: Go
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Time Wheel
[](https://pkg.go.dev/github.com/hyperjiang/timewheel)
[](https://github.com/hyperjiang/timewheel/actions/workflows/ci.yml)
[](https://goreportcard.com/report/github.com/hyperjiang/timewheel)
[](https://codecov.io/gh/hyperjiang/timewheel)
[](https://github.com/hyperjiang/timewheel/releases)
Simple time wheel in golang.
## Prerequisite
go version >= 1.18
## Usage
```
import "github.com/hyperjiang/timewheel"
type MyHandler struct {
}
func (h *MyHandler) Handle(param any) {
// do your own business
}
tw := timewheel.New(
timewheel.WithHandler(new(MyHandler)),
timewheel.WithLogger(timewheel.Printf),
timewheel.WithSlotNum(10),
timewheel.WithTickDuration(time.Millisecond*100),
)
tw.Start()
tw.AddTask(time.Second, "1s")
tw.AddTask(time.Second*10, "10s")
```