Refactor Notification Sending Logic to Use Goroutines
- Updated the Send method in NotificationHandler to send notifications asynchronously using goroutines, improving responsiveness and performance. - Removed synchronous error handling for notification sending, allowing the API to return a success response immediately while processing the notification in the background.
This commit is contained in:
@@ -45,9 +45,7 @@ func (h *NotificationHandler) Send(c echo.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Send notification
|
// Send notification
|
||||||
if err := h.service.Send(c.Request().Context(), &req); err != nil {
|
go h.service.Send(c.Request().Context(), &req)
|
||||||
return response.InternalServerError(c, "Failed to send notification")
|
|
||||||
}
|
|
||||||
|
|
||||||
return response.Created(c, nil, "Notification sent successfully")
|
return response.Created(c, nil, "Notification sent successfully")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user