feat(api): open incidents and notify channels when monitors go down
Results are evaluated as they arrive. Transitions open or resolve the monitor's incident and queue a notification per enabled channel in the same transaction; every API replica delivers the outbox with leases and exponential retries. Organizations manage webhook and email channels, can send test notifications and list incidents. Email requires UPTIME_SMTP_URL. Closes #14 Closes #15 Closes #16 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
01ef543e62
commit
5f42e3e650
12 files changed
+822
-13
No files matched your search
@@ -34,10 +34,17 @@ import (
|
||||
type env struct {
|
||||
srv *httptest.Server
|
||||
dbPool *pgxpool.Pool
|
||||
rdb *redis.Client
|
||||
api *api.Server
|
||||
}
|
||||
|
||||
func newEnv(t *testing.T) *env {
|
||||
t.Helper()
|
||||
return newEnvWith(t, nil)
|
||||
}
|
||||
|
||||
// newEnvWith lets a test adjust the API configuration before start.
|
||||
func newEnvWith(t *testing.T, adjust func(*config.API)) *env {
|
||||
t.Helper()
|
||||
dsn, redisURL := os.Getenv("UPTIME_TEST_DATABASE_URL"), os.Getenv("UPTIME_TEST_REDIS_URL")
|
||||
if dsn == "" || redisURL == "" {
|
||||
@@ -76,7 +83,7 @@ func newEnv(t *testing.T) *env {
|
||||
}
|
||||
log := slog.New(slog.DiscardHandler)
|
||||
|
||||
e := &env{dbPool: pool}
|
||||
e := &env{dbPool: pool, rdb: rdb}
|
||||
r := platform.NewRouter(log)
|
||||
e.srv = httptest.NewUnstartedServer(r)
|
||||
e.srv.StartTLS()
|
||||
@@ -90,6 +97,9 @@ func newEnv(t *testing.T) *env {
|
||||
PublicURL: e.srv.URL,
|
||||
SSOPrivateNetworks: "true",
|
||||
}
|
||||
if adjust != nil {
|
||||
adjust(&cfg)
|
||||
}
|
||||
e.api = api.New(cfg, api.Deps{Log: log, DB: tenant.New(pool), Redis: rdb, Keys: keys, Catalog: catalog})
|
||||
e.api.Mount(r)
|
||||
return e
|
||||
|
||||
Reference in new issue
Block a user