feat(server): запуск планировщика, /metrics, graceful shutdown

This commit is contained in:
2026-07-04 14:14:00 +07:00
parent 9475af441e
commit b31f886ae2
2 changed files with 93 additions and 11 deletions
+23
View File
@@ -2,7 +2,9 @@ package notify
import (
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"time"
@@ -76,3 +78,24 @@ func (d *Dispatcher) Send(ctx context.Context, projectID uuid.UUID, ev Event) er
}
return errors.Join(errs...)
}
// SendTest sends a single synthetic Event directly through the Notifier for
// channelType, bypassing project/channel lookup entirely. It satisfies
// api.TestSender and backs POST /channels/{cid}/test, letting a user verify
// a channel's bot_token/chat_id or webhook URL works before enabling the
// schedule — the api layer resolves the channel and decrypts its secret; this
// method only performs the actual delivery attempt.
func (d *Dispatcher) SendTest(ctx context.Context, channelType string, config json.RawMessage, secret string) error {
n, ok := d.byType[channelType]
if !ok {
return fmt.Errorf("notify: unknown channel type %q", channelType)
}
ev := Event{
Project: "test",
Domain: "test",
Status: "test",
Summary: "test notification",
At: time.Now(),
}
return n.Send(ctx, config, secret, ev)
}