Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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
}
```