Shares #109

Merged
amigan merged 59 commits from shareUI into trunk 2025-02-14 00:25:03 -05:00
2 changed files with 19 additions and 3 deletions
Showing only changes of commit cde862a2e7 - Show all commits

View file

@ -38,6 +38,7 @@ type Alerter interface {
Enabled() bool
Go(context.Context)
HUP(*config.Config)
stats
}
@ -101,9 +102,7 @@ func New(cfg config.Alerting, tgCache tgstore.Store, opts ...AlertOption) Alerte
tgCache: tgCache,
}
if cfg.Renotify != nil {
as.renotify = cfg.Renotify.Duration()
}
as.reload()
for _, opt := range opts {
opt(as)
@ -122,6 +121,21 @@ func New(cfg config.Alerting, tgCache tgstore.Store, opts ...AlertOption) Alerte
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.
func (as *alerter) Go(ctx context.Context) {
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) Go(_ context.Context) {}
func (*noopAlerter) Enabled() bool { return false }
func (*noopAlerter) HUP(_ *config.Config) { }

View file

@ -18,6 +18,7 @@ func (s *Server) huppers() []hupper {
s.logger,
s.auth,
s.tgs,
s.alerter,
}
}