From 5ac778ea537d945125605662f24f2a4f7663b55c Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Wed, 29 Apr 2026 13:54:17 +0000 Subject: [PATCH] Make the shutdown event a status message That way our status handlers on the frontend will know what additional data is available --- api/event.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/api/event.go b/api/event.go index 27e440c3..1ba713e7 100644 --- a/api/event.go +++ b/api/event.go @@ -7,12 +7,14 @@ import ( "time" "github.com/Gleipnir-Technology/nidus-sync/platform" + "github.com/Gleipnir-Technology/nidus-sync/platform/event" "github.com/Gleipnir-Technology/nidus-sync/version" "github.com/google/uuid" "github.com/rs/zerolog/log" ) var connectionsSSE map[*ConnectionSSE]bool = make(map[*ConnectionSSE]bool, 0) +var TYPE_STATUS string = "status" type ConnectionSSE struct { chanEvent chan platform.Event @@ -37,6 +39,16 @@ type Status struct { } func (c *ConnectionSSE) SendEvent(w http.ResponseWriter, m platform.Event) error { + if m.Type == event.EventTypeShutdown { + v := version.Get() + return send(w, Status{ + BuildTime: v.BuildTime, + IsModified: v.IsModified, + Revision: v.Revision, + Status: m.Type.String(), + Type: TYPE_STATUS, + }) + } return send(w, Message{ Resource: m.Resource, Time: m.Time, @@ -114,7 +126,7 @@ func streamEvents(w http.ResponseWriter, r *http.Request, u platform.User) { IsModified: v.IsModified, Revision: v.Revision, Status: "connected", - Type: "status", + Type: TYPE_STATUS, } body, err := json.Marshal(status) if err != nil {