Skip to content

Commit 4b79c50

Browse files
committed
Update event ID for Get
1 parent de2a2a0 commit 4b79c50

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

server/streamable_http.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -882,8 +882,22 @@ func (s *StreamableHTTPServer) handleGet(w http.ResponseWriter, r *http.Request)
882882
for {
883883
select {
884884
case notification := <-notificationCh:
885-
// Generate a unique ID for the notification
886-
eventID := uuid.New().String()
885+
// Store the event in the event store and get its ID
886+
var eventID string
887+
if session != nil && session.eventStore != nil {
888+
var err error
889+
eventID, err = session.eventStore.StoreEvent(streamID, notification)
890+
if err != nil {
891+
// Log the error but continue
892+
fmt.Printf("Error storing event: %v\n", err)
893+
// Use a generated UUID as fallback
894+
eventID = uuid.New().String()
895+
}
896+
} else {
897+
// Use a generated UUID if no event store is available
898+
eventID = uuid.New().String()
899+
}
900+
887901
if err := s.writeSSEEvent(streamID, "", eventID, notification); err != nil {
888902
fmt.Printf("Error writing notification: %v\n", err)
889903
}

0 commit comments

Comments
 (0)