fix(sse): some bugs
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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():
|
||||
|
||||
Reference in New Issue
Block a user