nurse/check/collection.go
Peter Kurfer c52912c5aa
Some checks failed
agola/nurse/Test and lint The run failed
refactor: migrate to new Gitea URL
2022-09-22 11:46:36 +02:00

31 lines
590 B
Go

package check
import (
"golang.org/x/sync/errgroup"
"code.icb4dc0.de/prskr/nurse/config"
"code.icb4dc0.de/prskr/nurse/grammar"
)
var _ SystemChecker = Collection(nil)
type Collection []SystemChecker
func (Collection) UnmarshalCheck(grammar.Check, config.ServerLookup) error {
panic("unmarshalling is not supported for a collection")
}
func (c Collection) Execute(ctx Context) error {
grp, grpCtx := errgroup.WithContext(ctx)
chkCtx := ctx.WithParent(grpCtx)
for i := range c {
chk := c[i]
grp.Go(func() error {
return chk.Execute(chkCtx)
})
}
return grp.Wait()
}