fix(sse): sending correctly formatted events & exiting function
This commit is contained in:
@ -46,6 +46,8 @@ func ListenNewImageEvents(db *sql.DB, eventManager *EventManager) {
|
||||
ctx := context.Background()
|
||||
|
||||
go func() {
|
||||
time.Sleep(10 * time.Second)
|
||||
|
||||
image, err := imageModel.GetToProcessWithData(ctx, imageId)
|
||||
if err != nil {
|
||||
databaseEventLog.Error("Failed to GetToProcessWithData", "error", err)
|
||||
|
@ -303,9 +303,10 @@ func main() {
|
||||
return
|
||||
case data := <-imageNotifier:
|
||||
fmt.Printf("Status received: %s\n", data)
|
||||
fmt.Fprintf(w, "data: %s-%s\n", data, time.Now().String())
|
||||
fmt.Fprintf(w, "event: data\ndata: %s-%s\n\n", data, time.Now().String())
|
||||
w.(http.Flusher).Flush()
|
||||
cancel()
|
||||
return
|
||||
}
|
||||
}
|
||||
})
|
||||
|
Reference in New Issue
Block a user