Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oze4/job-poc
concurrent jobs abstract easily
https://github.com/oze4/job-poc
Last synced: about 2 months ago
JSON representation
concurrent jobs abstract easily
- Host: GitHub
- URL: https://github.com/oze4/job-poc
- Owner: oze4
- License: mit
- Created: 2020-10-26T14:11:33.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-10-26T14:29:20.000Z (about 4 years ago)
- Last Synced: 2023-03-03T22:23:38.862Z (almost 2 years ago)
- Language: Go
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# job
- Example
See test file for detailed code
```golang
import "github.com/oze4/job"
func main() {
resultsChan := make(chan job.Result)
var results []job.Result
somejob := job.NewJob("SomeJob", resultsChan, func() (interface{}, error) {
time.Sleep(time.Second) // do something
return someResult, orSomeError
})
//// Invoke "manually"
go somejob.Run()
//// or pass to workerpool
// wp.Submit(somejob.Run) // github.com/gammazero/workerpool
// somejob.Run is just a `func()`
select {
case r := <-results:
results = append(results, r)
}
// do something with results
}
```