Commit 991539e4 by bergquist

style(go_routines): improve variable naming

parent 34b31aee
......@@ -60,10 +60,10 @@ func main() {
setting.BuildCommit = commit
setting.BuildStamp = buildstampInt64
appContext, cancelFn := context.WithCancel(context.Background())
grafanaGroup, _ := errgroup.WithContext(appContext)
appContext, shutdownFn := context.WithCancel(context.Background())
grafanaGroup, appContext := errgroup.WithContext(appContext)
go listenToSystemSignals(cancelFn, grafanaGroup)
go listenToSystemSignals(shutdownFn, grafanaGroup)
flag.Parse()
writePIDFile()
......
......@@ -39,7 +39,7 @@ func NewEngine() *Engine {
func (e *Engine) Start(grafanaCtx context.Context) error {
e.log.Info("Starting Alerting Engine")
g, _ := errgroup.WithContext(grafanaCtx)
g, grafanaCtx := errgroup.WithContext(grafanaCtx)
g.Go(func() error { return e.alertingTicker(grafanaCtx) })
g.Go(func() error { return e.execDispatcher(grafanaCtx) })
......@@ -90,7 +90,7 @@ func (e *Engine) execDispatcher(grafanaCtx context.Context) error {
}
}
func (e *Engine) executeJob(grafanaCtx context.Context, job *Job) {
func (e *Engine) executeJob(grafanaCtx context.Context, job *Job) error {
defer func() {
if err := recover(); err != nil {
e.log.Error("Execute Alert Panic", "error", err, "stack", log.Stack(1))
......@@ -108,11 +108,14 @@ func (e *Engine) executeJob(grafanaCtx context.Context, job *Job) {
}()
select {
case <-grafanaCtx.Done():
return grafanaCtx.Err()
case evalContext := <-done:
e.resultQueue <- evalContext
case <-grafanaCtx.Done():
}
return nil
}
func (e *Engine) resultDispatcher(grafanaCtx context.Context) error {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment