retry to send alert to plugin channel if it fails (#1530)
This commit is contained in:
parent
c2b298c93a
commit
39f7e38444
|
@ -99,11 +99,16 @@ func FormatAlerts(result []*ent.Alert) models.AddAlertsRequest {
|
||||||
|
|
||||||
func (c *Controller) sendAlertToPluginChannel(alert *models.Alert, profileID uint) {
|
func (c *Controller) sendAlertToPluginChannel(alert *models.Alert, profileID uint) {
|
||||||
if c.PluginChannel != nil {
|
if c.PluginChannel != nil {
|
||||||
select {
|
RETRY:
|
||||||
case c.PluginChannel <- csplugin.ProfileAlert{ProfileID: uint(profileID), Alert: alert}:
|
for try := 0; try < 3; try++ {
|
||||||
log.Debugf("alert sent to Plugin channel")
|
select {
|
||||||
default:
|
case c.PluginChannel <- csplugin.ProfileAlert{ProfileID: uint(profileID), Alert: alert}:
|
||||||
log.Warningf("Cannot send alert to Plugin channel")
|
log.Debugf("alert sent to Plugin channel")
|
||||||
|
break RETRY
|
||||||
|
default:
|
||||||
|
log.Warningf("Cannot send alert to Plugin channel (try: %d)", try)
|
||||||
|
time.Sleep(time.Millisecond * 50)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue