https://github.com/thetardigrade/golang-tasks
This package allows tasks to be set, whereby handler functions will run at given intervals.
https://github.com/thetardigrade/golang-tasks
go golang handler-functions interval-timer scheduled-tasks task-manager task-runner task-scheduler tasks time-management
Last synced: 5 months ago
JSON representation
This package allows tasks to be set, whereby handler functions will run at given intervals.
- Host: GitHub
- URL: https://github.com/thetardigrade/golang-tasks
- Owner: theTardigrade
- License: gpl-2.0
- Created: 2020-11-29T20:30:50.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-02-14T12:30:26.000Z (over 2 years ago)
- Last Synced: 2024-12-31T17:49:36.826Z (6 months ago)
- Topics: go, golang, handler-functions, interval-timer, scheduled-tasks, task-manager, task-runner, task-scheduler, tasks, time-management
- Language: Go
- Homepage:
- Size: 33.2 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# golang-tasks
This package allows tasks to be set, whereby handler functions will run at given intervals.
[](https://pkg.go.dev/github.com/theTardigrade/golang-tasks) [](https://goreportcard.com/report/github.com/theTardigrade/golang-tasks)
## Example
```golang
package mainimport (
"fmt"
"time"tasks "github.com/theTardigrade/golang-tasks"
)func main() {
// set up a handler function to run once every second;
// do not call the function on initialization
tasks.Set(time.Second, false, func(id *tasks.Identifier) {
fmt.Println("ONE SECOND HAS PASSED")// stop the task after five seconds
if id.DurationSinceSet() >= time.Second*5 {
id.Stop()
}
})// keep the main function running
select {}
}
```## Support
If you use this package, or find any value in it, please consider donating:
[](https://ko-fi.com/S6S2EIRL0)