Skip to content

Commit

Permalink
bus: revert alert change
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjan committed Mar 14, 2024
1 parent e3ce6e4 commit a156e4e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
5 changes: 1 addition & 4 deletions alerts/alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,7 @@ func (a *originAlerter) RegisterAlert(ctx context.Context, alert Alert) error {
if alert.Data == nil {
alert.Data = make(map[string]any)
}
_, set := alert.Data["origin"]
if !set {
alert.Data["origin"] = a.origin
}
alert.Data["origin"] = a.origin
return a.alerter.RegisterAlert(ctx, alert)
}

Expand Down
12 changes: 7 additions & 5 deletions bus/bus.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ type bus struct {
startTime time.Time

alerts alerts.Alerter
alertMgr *alerts.Manager
webhooks WebhookManager

cm ChainManager
Expand Down Expand Up @@ -1811,7 +1812,7 @@ func (b *bus) gougingParams(ctx context.Context) (api.GougingParams, error) {
}

func (b *bus) handleGETAlertsDeprecated(jc jape.Context) {
ar, err := b.alerts.Alerts(jc.Request.Context(), alerts.AlertsOpts{Offset: 0, Limit: -1})
ar, err := b.alertMgr.Alerts(jc.Request.Context(), alerts.AlertsOpts{Offset: 0, Limit: -1})
if jc.Check("failed to fetch alerts", err) != nil {
return
}
Expand All @@ -1835,7 +1836,7 @@ func (b *bus) handleGETAlerts(jc jape.Context) {
} else if jc.DecodeForm("severity", &severity) != nil {
return
}
ar, err := b.alerts.Alerts(jc.Request.Context(), alerts.AlertsOpts{
ar, err := b.alertMgr.Alerts(jc.Request.Context(), alerts.AlertsOpts{
Offset: offset,
Limit: limit,
Severity: severity,
Expand All @@ -1851,15 +1852,15 @@ func (b *bus) handlePOSTAlertsDismiss(jc jape.Context) {
if jc.Decode(&ids) != nil {
return
}
jc.Check("failed to dismiss alerts", b.alerts.DismissAlerts(jc.Request.Context(), ids...))
jc.Check("failed to dismiss alerts", b.alertMgr.DismissAlerts(jc.Request.Context(), ids...))
}

func (b *bus) handlePOSTAlertsRegister(jc jape.Context) {
var alert alerts.Alert
if jc.Decode(&alert) != nil {
return
}
jc.Check("failed to register alert", b.alerts.RegisterAlert(jc.Request.Context(), alert))
jc.Check("failed to register alert", b.alertMgr.RegisterAlert(jc.Request.Context(), alert))
}

func (b *bus) accountsHandlerGET(jc jape.Context) {
Expand Down Expand Up @@ -2388,9 +2389,10 @@ func (b *bus) multipartHandlerListPartsPOST(jc jape.Context) {
}

// New returns a new Bus.
func New(am alerts.Alerter, hm WebhookManager, cm ChainManager, s Syncer, w Wallet, hdb HostDB, as AutopilotStore, ms MetadataStore, ss SettingStore, eas EphemeralAccountStore, mtrcs MetricsStore, l *zap.Logger) (*bus, error) {
func New(am *alerts.Manager, hm WebhookManager, cm ChainManager, s Syncer, w Wallet, hdb HostDB, as AutopilotStore, ms MetadataStore, ss SettingStore, eas EphemeralAccountStore, mtrcs MetricsStore, l *zap.Logger) (*bus, error) {
b := &bus{
alerts: alerts.WithOrigin(am, "bus"),
alertMgr: am,
webhooks: hm,
cm: cm,
s: s,
Expand Down

0 comments on commit a156e4e

Please sign in to comment.