fix(sse): some bugs

This commit is contained in:
2025-04-27 14:56:06 +01:00
parent a9ecd5818a
commit 4922df6682
4 changed files with 30 additions and 9 deletions

View File

@@ -43,6 +43,8 @@ func ListenNewImageEvents(db *sql.DB, eventManager *EventManager) {
databaseEventLog.Debug("Starting processing image", "ImageID", imageId)
time.Sleep(5 * time.Second)
ctx := context.Background()
go func() {

View File

@@ -254,10 +254,15 @@ func main() {
id := r.PathValue("id")
// TODO: get the current status of the image and send it across.
ctx, cancel := context.WithCancel(r.Context())
imageNotifier, exists := eventManager.listeners[id]
if !exists {
fmt.Println("Not found!")
w.WriteHeader(http.StatusNotFound)
w.(http.Flusher).Flush()
cancel()
return
}
@@ -266,10 +271,6 @@ func main() {
w.Header().Set("Connection", "keep-alive")
w.(http.Flusher).Flush()
// TODO: get the current status of the image and send it across.
ctx, cancel := context.WithCancel(r.Context())
for {
select {
case <-ctx.Done():