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()
|
ctx := context.Background()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
time.Sleep(10 * time.Second)
|
||||||
|
|
||||||
image, err := imageModel.GetToProcessWithData(ctx, imageId)
|
image, err := imageModel.GetToProcessWithData(ctx, imageId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
databaseEventLog.Error("Failed to GetToProcessWithData", "error", err)
|
databaseEventLog.Error("Failed to GetToProcessWithData", "error", err)
|
||||||
|
@ -303,9 +303,10 @@ func main() {
|
|||||||
return
|
return
|
||||||
case data := <-imageNotifier:
|
case data := <-imageNotifier:
|
||||||
fmt.Printf("Status received: %s\n", data)
|
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()
|
w.(http.Flusher).Flush()
|
||||||
cancel()
|
cancel()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user