2022-05-13 13:38:19 +00:00
|
|
|
package check
|
|
|
|
|
|
|
|
import (
|
|
|
|
"golang.org/x/sync/errgroup"
|
|
|
|
|
2022-09-22 09:46:36 +00:00
|
|
|
"code.icb4dc0.de/prskr/nurse/config"
|
|
|
|
"code.icb4dc0.de/prskr/nurse/grammar"
|
2022-05-13 13:38:19 +00:00
|
|
|
)
|
|
|
|
|
2022-06-09 20:40:32 +00:00
|
|
|
var _ SystemChecker = Collection(nil)
|
2022-05-13 13:38:19 +00:00
|
|
|
|
|
|
|
type Collection []SystemChecker
|
|
|
|
|
|
|
|
func (Collection) UnmarshalCheck(grammar.Check, config.ServerLookup) error {
|
|
|
|
panic("unmarshalling is not supported for a collection")
|
|
|
|
}
|
|
|
|
|
2022-08-07 10:22:21 +00:00
|
|
|
func (c Collection) Execute(ctx Context) error {
|
2022-05-13 13:38:19 +00:00
|
|
|
grp, grpCtx := errgroup.WithContext(ctx)
|
|
|
|
|
2022-08-07 10:22:21 +00:00
|
|
|
chkCtx := ctx.WithParent(grpCtx)
|
|
|
|
|
2022-05-13 13:38:19 +00:00
|
|
|
for i := range c {
|
|
|
|
chk := c[i]
|
|
|
|
grp.Go(func() error {
|
2022-08-07 10:22:21 +00:00
|
|
|
return chk.Execute(chkCtx)
|
2022-05-13 13:38:19 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
return grp.Wait()
|
|
|
|
}
|