Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ferranbt/periodic-dispatcher
https://github.com/ferranbt/periodic-dispatcher
Last synced: 10 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/ferranbt/periodic-dispatcher
- Owner: ferranbt
- Created: 2018-11-08T16:57:26.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-11-08T16:58:34.000Z (about 6 years ago)
- Last Synced: 2023-08-11T18:40:17.647Z (over 1 year ago)
- Language: Go
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Periodic Dispatcher
Based on [Nomad](https://github.com/hashicorp/nomad) periodic dispatcher.
Launch multiple periodic jobs with a single thread.
```
package mainimport (
"fmt"
"time"
"github.com/ferranbt/periodic-dispatcher"
)type Job struct {
id string
}func (j *Job) ID() string {
return j.id
}func main() {
dispatcher := periodic.NewDispatcher()
dispatcher.SetEnabled(true)
dispatcher.Add(&Job{"a"}, 1*time.Second)
dispatcher.Add(&Job{"b"}, 2*time.Second)
for {
evnt := <-dispatcher.Events()
fmt.Println(evnt)
}
}
```