Skip to content

Commit 991539e

Browse files
committed
style(go_routines): improve variable naming
1 parent 34b31ae commit 991539e

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

pkg/cmd/grafana-server/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ func main() {
6060
setting.BuildCommit = commit
6161
setting.BuildStamp = buildstampInt64
6262

63-
appContext, cancelFn := context.WithCancel(context.Background())
64-
grafanaGroup, _ := errgroup.WithContext(appContext)
63+
appContext, shutdownFn := context.WithCancel(context.Background())
64+
grafanaGroup, appContext := errgroup.WithContext(appContext)
6565

66-
go listenToSystemSignals(cancelFn, grafanaGroup)
66+
go listenToSystemSignals(shutdownFn, grafanaGroup)
6767

6868
flag.Parse()
6969
writePIDFile()

pkg/services/alerting/engine.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func NewEngine() *Engine {
3939
func (e *Engine) Start(grafanaCtx context.Context) error {
4040
e.log.Info("Starting Alerting Engine")
4141

42-
g, _ := errgroup.WithContext(grafanaCtx)
42+
g, grafanaCtx := errgroup.WithContext(grafanaCtx)
4343

4444
g.Go(func() error { return e.alertingTicker(grafanaCtx) })
4545
g.Go(func() error { return e.execDispatcher(grafanaCtx) })
@@ -90,7 +90,7 @@ func (e *Engine) execDispatcher(grafanaCtx context.Context) error {
9090
}
9191
}
9292

93-
func (e *Engine) executeJob(grafanaCtx context.Context, job *Job) {
93+
func (e *Engine) executeJob(grafanaCtx context.Context, job *Job) error {
9494
defer func() {
9595
if err := recover(); err != nil {
9696
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) {
108108
}()
109109

110110
select {
111+
112+
case <-grafanaCtx.Done():
113+
return grafanaCtx.Err()
111114
case evalContext := <-done:
112115
e.resultQueue <- evalContext
113-
case <-grafanaCtx.Done():
114-
115116
}
117+
118+
return nil
116119
}
117120

118121
func (e *Engine) resultDispatcher(grafanaCtx context.Context) error {

0 commit comments

Comments
 (0)