TP-50597 | implemented get rca link api to support showing rca link in ui (#310)

* TP-38709 | Merging the changes to master on the logfix

* TP-50597 | Impelemented get rca link api to support Houston UI

* TP-50597 | Modified incident response to return rca link if exists or else return blank value

* TP-50597 | removed dead code

* TP-50597 | reverted changes for create incident workflow

* TP-50597 | removed cyclic dependency and added unit tests
This commit is contained in:
Ajay Devarakonda
2023-12-13 18:26:13 +05:30
committed by GitHub
parent a40785213b
commit 600c238a0c
6 changed files with 173 additions and 20 deletions

View File

@@ -9,8 +9,14 @@ import (
"houston/model/severity"
"houston/model/tag"
"houston/model/team"
"houston/model/user"
"houston/pkg/postgres"
"houston/pkg/rest"
rcaRepository "houston/repository/rca/impl"
"houston/repository/rcaInput"
"houston/service/documentService"
incidentService "houston/service/incident"
"houston/service/rca"
"houston/service/slack"
)
@@ -20,13 +26,17 @@ type applicationContext struct {
// todo: all the repo objects to be cleaned uo from here. appContext will only have services
type houstonServices struct {
logRepo *log.Repository
teamRepo *team.Repository
severityRepo *severity.Repository
incidentRepo *incident.Repository
slackService *slack.SlackService
incidentService *incidentService.IncidentServiceV2
tagRepo *tag.Repository
logRepo *log.Repository
teamRepo *team.Repository
severityRepo *severity.Repository
incidentRepo *incident.Repository
slackService *slack.SlackService
incidentService *incidentService.IncidentServiceV2
tagRepo *tag.Repository
rcaRepository *rcaRepository.Repository
rcaInputRepository *rcaInput.Repository
userRepository *user.Repository
rcaService *rca.RcaService
}
var appContext *applicationContext
@@ -44,13 +54,17 @@ func InitializeServices() {
teamRepo := initTeamRepo(logRepo)
slaService := initSlackService()
services = &houstonServices{
logRepo: logRepo,
teamRepo: teamRepo,
severityRepo: severityRepo,
incidentRepo: initIncidentRepo(severityRepo, logRepo, teamRepo, slaService.SocketModeClientWrapper.GetClient()),
slackService: slaService,
incidentService: initIncidentService(),
tagRepo: initTagRepo(),
logRepo: logRepo,
teamRepo: teamRepo,
severityRepo: severityRepo,
incidentRepo: initIncidentRepo(severityRepo, logRepo, teamRepo, slaService.SocketModeClientWrapper.GetClient()),
slackService: slaService,
incidentService: initIncidentService(),
tagRepo: initTagRepo(),
rcaRepository: initRCARepo(),
rcaInputRepository: initRCAInputRepo(),
userRepository: initUserRepo(),
rcaService: initRCAService(),
}
}
@@ -109,6 +123,23 @@ func initSlackService() *slack.SlackService {
return slack.NewSlackService()
}
func getRestClient() *rest.HttpRestClientImpl {
return rest.NewHttpRestClient()
}
func initDocumentService() *documentService.ActionsImpl {
return documentService.NewActionsImpl(getRestClient())
}
func GetDocumentService() *documentService.ActionsImpl {
return initDocumentService()
}
func initRCAService() *rca.RcaService {
rcaService := rca.NewRcaService(initIncidentService(), initSlackService(), getRestClient(), initDocumentService(), initRCARepo(), initRCAInputRepo(), initUserRepo())
return rcaService
}
func GetSlackService() *slack.SlackService {
return services.slackService
}
@@ -121,6 +152,9 @@ func GetIncidentService() *incidentService.IncidentServiceV2 {
return services.incidentService
}
func GetRCAService() *rca.RcaService {
return services.rcaService
}
func initTagRepo() *tag.Repository {
return tag.NewTagRepository(GetDB())
}
@@ -128,3 +162,27 @@ func initTagRepo() *tag.Repository {
func GetTagRepo() *tag.Repository {
return services.tagRepo
}
func initRCARepo() *rcaRepository.Repository {
return rcaRepository.NewRcaRepository(GetDB())
}
func GetRCARepo() *rcaRepository.Repository {
return services.rcaRepository
}
func initRCAInputRepo() *rcaInput.Repository {
return rcaInput.NewRcaInputRepository(GetDB())
}
func GetRCAInputRepo() *rcaInput.Repository {
return services.rcaInputRepository
}
func initUserRepo() *user.Repository {
return user.NewUserRepository(GetDB())
}
func GetUserRepo() *user.Repository {
return services.userRepository
}