Add service status and usage dashboard, refresh externally published edits
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user