Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: about 1 month 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 (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-02-14T12:30:26.000Z (almost 2 years ago)
- Last Synced: 2024-06-21T19:10:43.370Z (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.
[![Go Reference](https://pkg.go.dev/badge/github.com/theTardigrade/golang-tasks.svg)](https://pkg.go.dev/github.com/theTardigrade/golang-tasks) [![Go Report Card](https://goreportcard.com/badge/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:
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/S6S2EIRL0)