Add service status and usage dashboard, refresh externally published edits

This commit is contained in:
2026-10-09 20:20:44 +01:00
parent 67ac79765f
commit a50e8648f6
31 changed files with 1283 additions and 42 deletions
+8 -1
View File
@@ -17,6 +17,7 @@ import (
// Handler serves the persistent connection. Canceling ctx stops active clients.
func Handler(ctx context.Context, stores ...*pipeline.Store) http.Handler {
started := time.Now()
mux := http.NewServeMux()
var runs *runner
var runErr error
@@ -66,7 +67,10 @@ func Handler(ctx context.Context, stores ...*pipeline.Store) http.Handler {
if request.Type == protocol.List || request.Type == protocol.Submit {
response.NotificationEndpoints = notificationEndpoints()
}
if request.Type == protocol.Ping {
if request.Type == protocol.GetStatus {
response.Type = protocol.Status
response.Status = systemStatus(r, started, runErr)
} else if request.Type == protocol.Ping {
response.Time = time.Now().UTC().Format(time.RFC3339)
} else if request.Type == protocol.ListTemplates {
response.Type = protocol.Templates
@@ -133,6 +137,9 @@ func Handler(ctx context.Context, stores ...*pipeline.Store) http.Handler {
case protocol.ListRuns:
response.Type = protocol.Runs
response.Runs, err = runs.listRuns()
if err == nil {
response.Usage, err = stores[0].UsageStats(ctx)
}
case protocol.GetRun:
response.Type = protocol.Run
response.RunDetail, err = runs.getRun(request.RunID)