Files
houston-be/cmd/app/handler/reminder_handler.go
Vijay Joshi 602db7741c INFRA-2887 : Incident reminder dm cron refactor/re-implementation (#413)
* INFRA-2887 : Incident reminder cron refactor/reimplementation

* INFRA-2887 : remove cron code

* INFRA-2887 : remove comment

* INFRA-2887 : Minor changes

* INFRA-2887 : PR comments

* INFRA-3121 : CLEANUP CRON, remove shedlock table and add UT's

* INFRA-2887 : Add default ack

* INFRA-2887 : Handler changes
2024-04-02 18:49:11 +05:30

50 lines
1.5 KiB
Go

package handler
import (
"github.com/gin-gonic/gin"
"houston/appcontext"
"houston/common/metrics"
"houston/service/reminder"
common "houston/service/response/common"
"net/http"
)
type ReminderHandler struct {
gin *gin.Engine
service reminder.ReminderService
}
func NewReminderHandler(
gin *gin.Engine,
) *ReminderHandler {
return &ReminderHandler{
gin: gin,
service: appcontext.GetReminderService(),
}
}
func (handler *ReminderHandler) HandleTeamIncidents(c *gin.Context) {
err := handler.service.PostTeamIncidents()
if err != nil {
c.JSON(http.StatusInternalServerError, common.ErrorResponse(err, http.StatusInternalServerError, nil))
metrics.PublishHoustonFlowFailureMetrics("TEAM_INCIDENTS_REMINDER", err.Error())
return
}
c.JSON(http.StatusOK, common.SuccessResponse("Team metrics posted successfully", http.StatusOK))
}
func (handler *ReminderHandler) HandleSlaBreachReminder(c *gin.Context) {
err := handler.service.PostSlaBreachMessages()
if err != nil {
c.JSON(http.StatusInternalServerError, common.ErrorResponse(err, http.StatusInternalServerError, nil))
metrics.PublishHoustonFlowFailureMetrics("SLA_BREACH_REMINDER", err.Error())
return
}
c.JSON(http.StatusOK, common.SuccessResponse("SLA breach reminder posted successfully", http.StatusOK))
}
func (handler *ReminderHandler) HandleUserIncidents(c *gin.Context) {
handler.service.SendIncidentReminder()
c.JSON(http.StatusOK, common.SuccessResponse("Acknowledged request to send incident reminder", http.StatusOK))
}