https://github.com/lestrrat-go/rungroup
Control execution of multiple goroutines
https://github.com/lestrrat-go/rungroup
Last synced: 5 days ago
JSON representation
Control execution of multiple goroutines
- Host: GitHub
- URL: https://github.com/lestrrat-go/rungroup
- Owner: lestrrat-go
- License: mit
- Created: 2022-02-18T04:09:09.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-03-04T09:48:44.000Z (over 3 years ago)
- Last Synced: 2025-02-26T11:14:37.548Z (4 months ago)
- Language: Go
- Size: 3.91 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
rungroup
========Control multiple goroutines from one object.
```go
var g rungroup.Groupfor i := 0; i < 10; i++ {
i := i
g.Add(rungroup.ActorFunc(func(ctx context.Context) error {
if i%2 == 1 {
return fmt.Errorf(`%d`, i)
}
return nil
}))
}ctx, cancel := context.WithCancel(context.Background())
defer cancel()
err := g.Run(ctx)time.Sleep(time.Second)
cancel()if !assert.Len(t, err, 5) {
return
}
```