Shares #109
2 changed files with 19 additions and 3 deletions
|
@ -38,6 +38,7 @@ type Alerter interface {
|
||||||
|
|
||||||
Enabled() bool
|
Enabled() bool
|
||||||
Go(context.Context)
|
Go(context.Context)
|
||||||
|
HUP(*config.Config)
|
||||||
|
|
||||||
stats
|
stats
|
||||||
}
|
}
|
||||||
|
@ -101,9 +102,7 @@ func New(cfg config.Alerting, tgCache tgstore.Store, opts ...AlertOption) Alerte
|
||||||
tgCache: tgCache,
|
tgCache: tgCache,
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfg.Renotify != nil {
|
as.reload()
|
||||||
as.renotify = cfg.Renotify.Duration()
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
opt(as)
|
opt(as)
|
||||||
|
@ -122,6 +121,21 @@ func New(cfg config.Alerting, tgCache tgstore.Store, opts ...AlertOption) Alerte
|
||||||
return as
|
return as
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (as *alerter) reload() {
|
||||||
|
if as.cfg.Renotify != nil {
|
||||||
|
as.renotify = as.cfg.Renotify.Duration()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (as *alerter) HUP(cfg *config.Config) {
|
||||||
|
as.Lock()
|
||||||
|
defer as.Unlock()
|
||||||
|
|
||||||
|
log.Debug().Msg("reloading alert config")
|
||||||
|
as.cfg = cfg.Alerting
|
||||||
|
as.reload()
|
||||||
|
}
|
||||||
|
|
||||||
// Go is the alerting loop. It does not start a goroutine.
|
// Go is the alerting loop. It does not start a goroutine.
|
||||||
func (as *alerter) Go(ctx context.Context) {
|
func (as *alerter) Go(ctx context.Context) {
|
||||||
ctx = entities.CtxWithSubject(ctx, &entities.SystemServiceSubject{Name: "alerter"})
|
ctx = entities.CtxWithSubject(ctx, &entities.SystemServiceSubject{Name: "alerter"})
|
||||||
|
@ -381,3 +395,4 @@ func (*noopAlerter) SinkType() string { return "noopA
|
||||||
func (*noopAlerter) Call(_ context.Context, _ *calls.Call) error { return nil }
|
func (*noopAlerter) Call(_ context.Context, _ *calls.Call) error { return nil }
|
||||||
func (*noopAlerter) Go(_ context.Context) {}
|
func (*noopAlerter) Go(_ context.Context) {}
|
||||||
func (*noopAlerter) Enabled() bool { return false }
|
func (*noopAlerter) Enabled() bool { return false }
|
||||||
|
func (*noopAlerter) HUP(_ *config.Config) { }
|
||||||
|
|
|
@ -18,6 +18,7 @@ func (s *Server) huppers() []hupper {
|
||||||
s.logger,
|
s.logger,
|
||||||
s.auth,
|
s.auth,
|
||||||
s.tgs,
|
s.tgs,
|
||||||
|
s.alerter,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue