diff options
| author | Paul Buetow <paul@buetow.org> | 2023-04-25 00:16:39 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2023-04-25 00:16:39 +0300 |
| commit | b4b85046fef253d28f8e90ad76dca2e7552fe0ab (patch) | |
| tree | 44e7f41cdcbabdbce2f134753be9828799f58066 /internal/runchecks.go | |
| parent | 3abf436db869c99586ff55af9bd562a33d114607 (diff) | |
add DependsOn
Diffstat (limited to 'internal/runchecks.go')
| -rw-r--r-- | internal/runchecks.go | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/internal/runchecks.go b/internal/runchecks.go index 360a1b5..48a80e8 100644 --- a/internal/runchecks.go +++ b/internal/runchecks.go @@ -11,6 +11,7 @@ func runChecks(globalCtx context.Context, state state, config config) state { limiterCh := make(chan struct{}, config.CheckConcurrency) inputCh := make(chan namedCheck) outputCh := make(chan checkResult) + deps := newDependency(config) go func() { for name, check := range config.Checks { @@ -34,17 +35,30 @@ func runChecks(globalCtx context.Context, state state, config config) state { for check := range inputCh { go func(check namedCheck) { + defer inputWg.Done() + + if err := deps.wait(globalCtx, check.DependsOn); err != nil { + deps.notOk(check.name) + outputCh <- check.skip(err.Error()) + return + } + limiterCh <- struct{}{} - defer func() { - <-limiterCh - inputWg.Done() - }() + defer func() { <-limiterCh }() ctx, cancel := context.WithTimeout(globalCtx, time.Duration(config.CheckTimeoutS)*time.Second) defer cancel() - outputCh <- check.run(ctx) + checkResult := check.run(ctx) + + if checkResult.status == critical { + deps.notOk(check.name) + } else { + deps.ok(check.name) + } + + outputCh <- checkResult }(check) } |
