summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2023-04-19 20:45:10 +0300
committerPaul Buetow <paul@buetow.org>2023-04-19 20:45:10 +0300
commit919cdfd15447846ee4d3acffb7570463897a7722 (patch)
treedd822801a58873b63e342ad510cb13d7696d98f7 /internal
parente023a59312c3fa5e768dfea6b73c7647242a9f5a (diff)
add global timeout
Diffstat (limited to 'internal')
-rw-r--r--internal/execute.go4
-rw-r--r--internal/run.go6
2 files changed, 6 insertions, 4 deletions
diff --git a/internal/execute.go b/internal/execute.go
index d8f426f..1029ff7 100644
--- a/internal/execute.go
+++ b/internal/execute.go
@@ -7,7 +7,7 @@ import (
"time"
)
-func execute(state state, config config) state {
+func execute(globalCtx context.Context, state state, config config) state {
limiterCh := make(chan struct{}, config.CheckConcurrency)
inputCh := make(chan namedCheck)
outputCh := make(chan checkResult)
@@ -40,7 +40,7 @@ func execute(state state, config config) state {
inputWg.Done()
}()
- ctx, cancel := context.WithTimeout(context.Background(),
+ ctx, cancel := context.WithTimeout(globalCtx,
time.Duration(config.CheckTimeoutS)*time.Second)
defer cancel()
diff --git a/internal/run.go b/internal/run.go
index 417b81b..ef9919d 100644
--- a/internal/run.go
+++ b/internal/run.go
@@ -1,6 +1,8 @@
package internal
-func Run(configFile string) {
+import "context"
+
+func Run(cts context.Context, configFile string) {
config, err := newConfig(configFile)
if err != nil {
panic(err)
@@ -11,7 +13,7 @@ func Run(configFile string) {
notifyError(config, err)
}
- state = execute(state, config)
+ state = execute(ctx, state, config)
if err := state.persist(); err != nil {
notifyError(config, err)