mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
notifications: send notifications synchronous
This commit is contained in:
parent
d31c7bc6a4
commit
e91e3ea771
@ -6,8 +6,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"golang.org/x/sync/errgroup"
|
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/bus"
|
"github.com/grafana/grafana/pkg/bus"
|
||||||
"github.com/grafana/grafana/pkg/components/imguploader"
|
"github.com/grafana/grafana/pkg/components/imguploader"
|
||||||
"github.com/grafana/grafana/pkg/log"
|
"github.com/grafana/grafana/pkg/log"
|
||||||
@ -61,13 +59,10 @@ func (n *notificationService) SendIfNeeded(context *EvalContext) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (n *notificationService) sendNotifications(evalContext *EvalContext, notifiers []Notifier) error {
|
func (n *notificationService) sendNotifications(evalContext *EvalContext, notifiers []Notifier) error {
|
||||||
g, _ := errgroup.WithContext(evalContext.Ctx)
|
|
||||||
|
|
||||||
for _, notifier := range notifiers {
|
for _, notifier := range notifiers {
|
||||||
not := notifier //avoid updating scope variable in go routine
|
not := notifier
|
||||||
|
|
||||||
g.Go(func() error {
|
err := bus.InTransaction(evalContext.Ctx, func(ctx context.Context) error {
|
||||||
return bus.InTransaction(evalContext.Ctx, func(ctx context.Context) error {
|
|
||||||
n.log.Debug("trying to send notification", "id", not.GetNotifierId())
|
n.log.Debug("trying to send notification", "id", not.GetNotifierId())
|
||||||
|
|
||||||
// Verify that we can send the notification again
|
// Verify that we can send the notification again
|
||||||
@ -93,10 +88,13 @@ func (n *notificationService) sendNotifications(evalContext *EvalContext, notifi
|
|||||||
|
|
||||||
return bus.DispatchCtx(ctx, cmd)
|
return bus.DispatchCtx(ctx, cmd)
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return g.Wait()
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *notificationService) uploadImage(context *EvalContext) (err error) {
|
func (n *notificationService) uploadImage(context *EvalContext) (err error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user