From 6d8fa5db1c08d13ffde0a1d682e15dc63cee7c9a Mon Sep 17 00:00:00 2001 From: F-cq <2036478450@qq.com> Date: Wed, 4 Feb 2026 16:49:17 +0800 Subject: [PATCH] feat(backend): Add admin strategy eventnames list api and remove trigger_event_name_reason. issue: #16212 --- dbm-services/common/dbha-v2/docs/docs.go | 73 +++---- .../admin/api/open/handler/strategy.go | 204 +++++++++--------- .../dbha-v2/internal/admin/api/open/router.go | 7 + .../admin/api/open/serializer/strategy.go | 59 +++-- .../internal/admin/strategy/strategy.go | 2 - .../dbha-v2/pkg/storage/haprobe/db_event.go | 16 +- 6 files changed, 184 insertions(+), 177 deletions(-) diff --git a/dbm-services/common/dbha-v2/docs/docs.go b/dbm-services/common/dbha-v2/docs/docs.go index 140ddf95e7..69348d8241 100644 --- a/dbm-services/common/dbha-v2/docs/docs.go +++ b/dbm-services/common/dbha-v2/docs/docs.go @@ -473,6 +473,32 @@ const docTemplate = `{ } } }, + "/api/admin/strategies/eventnames/": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "openapi.strategy" + ], + "summary": "strategy trigger event names list", + "operationId": "openapi_strategy_trigger_event_names_list", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + }, "/api/admin/strategies/{id}/": { "get": { "consumes": [ @@ -649,9 +675,6 @@ const docTemplate = `{ }, "trigger_event_name": { "$ref": "#/definitions/dbm-services_common_dbha-v2_pkg_storage_haprobe.DbEventName" - }, - "trigger_event_name_reason": { - "$ref": "#/definitions/dbm-services_common_dbha-v2_pkg_storage_haprobe.DbEventNameReason" } } }, @@ -693,9 +716,6 @@ const docTemplate = `{ }, "trigger_event_name": { "$ref": "#/definitions/dbm-services_common_dbha-v2_pkg_storage_haprobe.DbEventName" - }, - "trigger_event_name_reason": { - "$ref": "#/definitions/dbm-services_common_dbha-v2_pkg_storage_haprobe.DbEventNameReason" } } }, @@ -779,8 +799,7 @@ const docTemplate = `{ "type": "object", "required": [ "bk_biz_id", - "name", - "trigger_event_name" + "name" ], "properties": { "action": { @@ -809,9 +828,6 @@ const docTemplate = `{ }, "trigger_event_name": { "$ref": "#/definitions/dbm-services_common_dbha-v2_pkg_storage_haprobe.DbEventName" - }, - "trigger_event_name_reason": { - "$ref": "#/definitions/dbm-services_common_dbha-v2_pkg_storage_haprobe.DbEventNameReason" } } }, @@ -819,8 +835,7 @@ const docTemplate = `{ "type": "object", "required": [ "bk_biz_id", - "name", - "trigger_event_name" + "name" ], "properties": { "action": { @@ -849,9 +864,6 @@ const docTemplate = `{ }, "trigger_event_name": { "$ref": "#/definitions/dbm-services_common_dbha-v2_pkg_storage_haprobe.DbEventName" - }, - "trigger_event_name_reason": { - "$ref": "#/definitions/dbm-services_common_dbha-v2_pkg_storage_haprobe.DbEventNameReason" } } }, @@ -859,8 +871,7 @@ const docTemplate = `{ "type": "object", "required": [ "bk_biz_id", - "name", - "trigger_event_name" + "name" ], "properties": { "action": { @@ -896,9 +907,6 @@ const docTemplate = `{ "trigger_event_name": { "$ref": "#/definitions/dbm-services_common_dbha-v2_pkg_storage_haprobe.DbEventName" }, - "trigger_event_name_reason": { - "$ref": "#/definitions/dbm-services_common_dbha-v2_pkg_storage_haprobe.DbEventNameReason" - }, "updated_at": { "type": "string" } @@ -923,8 +931,7 @@ const docTemplate = `{ "type": "object", "required": [ "bk_biz_id", - "name", - "trigger_event_name" + "name" ], "properties": { "action": { @@ -953,9 +960,6 @@ const docTemplate = `{ }, "trigger_event_name": { "$ref": "#/definitions/dbm-services_common_dbha-v2_pkg_storage_haprobe.DbEventName" - }, - "trigger_event_name_reason": { - "$ref": "#/definitions/dbm-services_common_dbha-v2_pkg_storage_haprobe.DbEventNameReason" } } }, @@ -1051,23 +1055,6 @@ const docTemplate = `{ "DbEventNameDetectSSHFailure", "DbEventNameProbeOffline" ] - }, - "dbm-services_common_dbha-v2_pkg_storage_haprobe.DbEventNameReason": { - "type": "integer", - "enum": [ - 0, - 1, - 2, - 3, - 4 - ], - "x-enum-varnames": [ - "DbEventNameReasonConnectionException", - "DbEventNameReasonAuthException", - "DbEventNameReasonSSHAuthException", - "DbEventNameReasonMissedProbe", - "DbEventNameReasonNoTarget" - ] } } }` diff --git a/dbm-services/common/dbha-v2/internal/admin/api/open/handler/strategy.go b/dbm-services/common/dbha-v2/internal/admin/api/open/handler/strategy.go index 772ac5877d..ad2a1c52ac 100644 --- a/dbm-services/common/dbha-v2/internal/admin/api/open/handler/strategy.go +++ b/dbm-services/common/dbha-v2/internal/admin/api/open/handler/strategy.go @@ -30,6 +30,7 @@ import ( "dbm-services/common/dbha-v2/internal/admin/strategy" "dbm-services/common/dbha-v2/pkg/hanet" "dbm-services/common/dbha-v2/pkg/storage/hamodel" + "dbm-services/common/dbha-v2/pkg/storage/haprobe" "github.com/gin-gonic/gin" ) @@ -74,16 +75,15 @@ func (h *StrategyHandler) Create(c *gin.Context) { } strategyInfo := &hamodel.DbSwitchingStrategy{ - Name: req.Name, - BkBizID: req.BkBizID, - TriggerEventName: req.TriggerEventName, - TriggerEventNameReason: req.TriggerEventNameReason, - TriggerCount: req.TriggerCount, - Priority: req.Priority, - Scope: req.Scope, - Action: req.Action, - Description: req.Description, - Status: hamodel.StatusTypeEnabled, + Name: req.Name, + BkBizID: req.BkBizID, + TriggerEventName: req.TriggerEventName, + TriggerCount: req.TriggerCount, + Priority: req.Priority, + Scope: req.Scope, + Action: req.Action, + Description: req.Description, + Status: hamodel.StatusTypeEnabled, } if err := h.strategyService.CreateStrategy(strategyInfo); err != nil { @@ -123,16 +123,15 @@ func (h *StrategyHandler) BatchCreate(c *gin.Context) { names = append(names, strategyInfo.Name) nameIDMap[strategyInfo.Name] = strategyInfo.ID strategies = append(strategies, &hamodel.DbSwitchingStrategy{ - Name: strategyInfo.Name, - BkBizID: strategyInfo.BkBizID, - TriggerEventName: strategyInfo.TriggerEventName, - TriggerEventNameReason: strategyInfo.TriggerEventNameReason, - TriggerCount: strategyInfo.TriggerCount, - Priority: strategyInfo.Priority, - Scope: strategyInfo.Scope, - Action: strategyInfo.Action, - Description: strategyInfo.Description, - Status: hamodel.StatusTypeEnabled, + Name: strategyInfo.Name, + BkBizID: strategyInfo.BkBizID, + TriggerEventName: strategyInfo.TriggerEventName, + TriggerCount: strategyInfo.TriggerCount, + Priority: strategyInfo.Priority, + Scope: strategyInfo.Scope, + Action: strategyInfo.Action, + Description: strategyInfo.Description, + Status: hamodel.StatusTypeEnabled, }) } @@ -183,16 +182,15 @@ func (h *StrategyHandler) BatchUpdate(c *gin.Context) { names = append(names, strategyInfo.Name) nameIDMap[strategyInfo.Name] = strategyInfo.ID strategies = append(strategies, &hamodel.DbSwitchingStrategy{ - ID: strategyInfo.ID, - Name: strategyInfo.Name, - BkBizID: strategyInfo.BkBizID, - TriggerEventName: strategyInfo.TriggerEventName, - TriggerEventNameReason: strategyInfo.TriggerEventNameReason, - TriggerCount: strategyInfo.TriggerCount, - Priority: strategyInfo.Priority, - Scope: strategyInfo.Scope, - Action: strategyInfo.Action, - Description: strategyInfo.Description, + ID: strategyInfo.ID, + Name: strategyInfo.Name, + BkBizID: strategyInfo.BkBizID, + TriggerEventName: strategyInfo.TriggerEventName, + TriggerCount: strategyInfo.TriggerCount, + Priority: strategyInfo.Priority, + Scope: strategyInfo.Scope, + Action: strategyInfo.Action, + Description: strategyInfo.Description, }) } @@ -264,6 +262,19 @@ func (h *StrategyHandler) BatchUpdateStatus(c *gin.Context) { ginx.SuccessNoContentResponse(c) } +// TriggerEventNamesList lists trigger event names +// +// @ID openapi_strategy_trigger_event_names_list +// @Summary strategy trigger event names list +// @Accept json +// @Produce json +// @Tags openapi.strategy +// @Success 200 {object} []string +// @Router /api/admin/strategies/eventnames/ [get] +func (h *StrategyHandler) TriggerEventNamesList(c *gin.Context) { + ginx.SuccessJSONResponse(c, haprobe.DbEventNameList) +} + // List lists strategies // // @ID openapi_strategy_list @@ -300,16 +311,15 @@ func (h *StrategyHandler) List(c *gin.Context) { for _, strategyInfo := range strategies { output = append(output, serializer.StrategyOutputInfo{ StrategyInfo: serializer.StrategyInfo{ - ID: strategyInfo.ID, - Name: strategyInfo.Name, - BkBizID: strategyInfo.BkBizID, - TriggerEventName: strategyInfo.TriggerEventName, - TriggerEventNameReason: strategyInfo.TriggerEventNameReason, - TriggerCount: strategyInfo.TriggerCount, - Priority: strategyInfo.Priority, - Scope: strategyInfo.Scope, - Action: strategyInfo.Action, - Description: strategyInfo.Description, + ID: strategyInfo.ID, + Name: strategyInfo.Name, + BkBizID: strategyInfo.BkBizID, + TriggerEventName: strategyInfo.TriggerEventName, + TriggerCount: strategyInfo.TriggerCount, + Priority: strategyInfo.Priority, + Scope: strategyInfo.Scope, + Action: strategyInfo.Action, + Description: strategyInfo.Description, }, Status: strategyInfo.Status, CreatedAt: strategyInfo.CreatedAt, @@ -357,16 +367,15 @@ func (h *StrategyHandler) Get(c *gin.Context) { output := serializer.StrategyOutputInfo{ StrategyInfo: serializer.StrategyInfo{ - ID: strategyInfo.ID, - Name: strategyInfo.Name, - BkBizID: strategyInfo.BkBizID, - TriggerEventName: strategyInfo.TriggerEventName, - TriggerEventNameReason: strategyInfo.TriggerEventNameReason, - TriggerCount: strategyInfo.TriggerCount, - Priority: strategyInfo.Priority, - Scope: strategyInfo.Scope, - Action: strategyInfo.Action, - Description: strategyInfo.Description, + ID: strategyInfo.ID, + Name: strategyInfo.Name, + BkBizID: strategyInfo.BkBizID, + TriggerEventName: strategyInfo.TriggerEventName, + TriggerCount: strategyInfo.TriggerCount, + Priority: strategyInfo.Priority, + Scope: strategyInfo.Scope, + Action: strategyInfo.Action, + Description: strategyInfo.Description, }, Status: strategyInfo.Status, CreatedAt: strategyInfo.CreatedAt, @@ -421,16 +430,15 @@ func (h *StrategyHandler) Update(c *gin.Context) { } strategyInfo := &hamodel.DbSwitchingStrategy{ - ID: pathParam.ID, - Name: req.Name, - BkBizID: req.BkBizID, - TriggerEventName: req.TriggerEventName, - TriggerEventNameReason: req.TriggerEventNameReason, - TriggerCount: req.TriggerCount, - Priority: req.Priority, - Scope: req.Scope, - Action: req.Action, - Description: req.Description, + ID: pathParam.ID, + Name: req.Name, + BkBizID: req.BkBizID, + TriggerEventName: req.TriggerEventName, + TriggerCount: req.TriggerCount, + Priority: req.Priority, + Scope: req.Scope, + Action: req.Action, + Description: req.Description, } if err := h.strategyService.UpdateStrategy(strategyInfo); err != nil { @@ -561,16 +569,15 @@ func (h *StrategyHandler) GlobalList(c *gin.Context) { for _, strategyInfo := range strategies { output = append(output, serializer.StrategyOutputInfo{ StrategyInfo: serializer.StrategyInfo{ - ID: strategyInfo.ID, - Name: strategyInfo.Name, - BkBizID: strategyInfo.BkBizID, - TriggerEventName: strategyInfo.TriggerEventName, - TriggerEventNameReason: strategyInfo.TriggerEventNameReason, - TriggerCount: strategyInfo.TriggerCount, - Priority: strategyInfo.Priority, - Scope: strategyInfo.Scope, - Action: strategyInfo.Action, - Description: strategyInfo.Description, + ID: strategyInfo.ID, + Name: strategyInfo.Name, + BkBizID: strategyInfo.BkBizID, + TriggerEventName: strategyInfo.TriggerEventName, + TriggerCount: strategyInfo.TriggerCount, + Priority: strategyInfo.Priority, + Scope: strategyInfo.Scope, + Action: strategyInfo.Action, + Description: strategyInfo.Description, }, Status: strategyInfo.Status, CreatedAt: strategyInfo.CreatedAt, @@ -609,16 +616,15 @@ func (h *StrategyHandler) GlobalCreate(c *gin.Context) { } strategyInfo := &hamodel.DbSwitchingStrategy{ - Name: req.Name, - BkBizID: 0, - TriggerEventName: req.TriggerEventName, - TriggerEventNameReason: req.TriggerEventNameReason, - TriggerCount: req.TriggerCount, - Priority: req.Priority, - Scope: req.Scope, - Action: req.Action, - Description: req.Description, - Status: hamodel.StatusTypeEnabled, + Name: req.Name, + BkBizID: 0, + TriggerEventName: req.TriggerEventName, + TriggerCount: req.TriggerCount, + Priority: req.Priority, + Scope: req.Scope, + Action: req.Action, + Description: req.Description, + Status: hamodel.StatusTypeEnabled, } if err := h.strategyService.CreateStrategy(strategyInfo); err != nil { @@ -659,16 +665,15 @@ func (h *StrategyHandler) GlobalGet(c *gin.Context) { output := serializer.StrategyOutputInfo{ StrategyInfo: serializer.StrategyInfo{ - ID: strategyInfo.ID, - Name: strategyInfo.Name, - BkBizID: strategyInfo.BkBizID, - TriggerEventName: strategyInfo.TriggerEventName, - TriggerEventNameReason: strategyInfo.TriggerEventNameReason, - TriggerCount: strategyInfo.TriggerCount, - Priority: strategyInfo.Priority, - Scope: strategyInfo.Scope, - Action: strategyInfo.Action, - Description: strategyInfo.Description, + ID: strategyInfo.ID, + Name: strategyInfo.Name, + BkBizID: strategyInfo.BkBizID, + TriggerEventName: strategyInfo.TriggerEventName, + TriggerCount: strategyInfo.TriggerCount, + Priority: strategyInfo.Priority, + Scope: strategyInfo.Scope, + Action: strategyInfo.Action, + Description: strategyInfo.Description, }, Status: strategyInfo.Status, CreatedAt: strategyInfo.CreatedAt, @@ -723,16 +728,15 @@ func (h *StrategyHandler) GlobalUpdate(c *gin.Context) { } strategyInfo := &hamodel.DbSwitchingStrategy{ - ID: pathParam.ID, - Name: req.Name, - BkBizID: 0, - TriggerEventName: req.TriggerEventName, - TriggerEventNameReason: req.TriggerEventNameReason, - TriggerCount: req.TriggerCount, - Priority: req.Priority, - Scope: req.Scope, - Action: req.Action, - Description: req.Description, + ID: pathParam.ID, + Name: req.Name, + BkBizID: 0, + TriggerEventName: req.TriggerEventName, + TriggerCount: req.TriggerCount, + Priority: req.Priority, + Scope: req.Scope, + Action: req.Action, + Description: req.Description, } if err := h.strategyService.UpdateStrategy(strategyInfo); err != nil { diff --git a/dbm-services/common/dbha-v2/internal/admin/api/open/router.go b/dbm-services/common/dbha-v2/internal/admin/api/open/router.go index 8f999fb4c9..5790e28004 100644 --- a/dbm-services/common/dbha-v2/internal/admin/api/open/router.go +++ b/dbm-services/common/dbha-v2/internal/admin/api/open/router.go @@ -73,6 +73,13 @@ func RegisterStrategyApi(strategyHandler *handler.StrategyHandler, server *hanet Handler: strategyHandler.BatchUpdateStatus, }) + server.RegisterAPI(&hanet.ResetAPI{ + Group: group, + Method: hanet.HttpMethodGet, + Path: "/eventnames/", + Handler: strategyHandler.TriggerEventNamesList, + }) + server.RegisterAPI(&hanet.ResetAPI{ Group: group, Method: hanet.HttpMethodGet, diff --git a/dbm-services/common/dbha-v2/internal/admin/api/open/serializer/strategy.go b/dbm-services/common/dbha-v2/internal/admin/api/open/serializer/strategy.go index eb53c99ef6..8e785adab7 100644 --- a/dbm-services/common/dbha-v2/internal/admin/api/open/serializer/strategy.go +++ b/dbm-services/common/dbha-v2/internal/admin/api/open/serializer/strategy.go @@ -48,16 +48,15 @@ type StrategyRequest struct { // StrategyInfo strategy info type StrategyInfo struct { - ID int `json:"id"` - Name string `json:"name" binding:"required"` - BkBizID int `json:"bk_biz_id" binding:"required"` - TriggerEventName haprobe.DbEventName `json:"trigger_event_name" binding:"required"` - TriggerEventNameReason haprobe.DbEventNameReason `json:"trigger_event_name_reason" validate:"triggerEventNameReason"` - TriggerCount int `json:"trigger_count" validate:"triggerCount"` - Priority int `json:"priority" validate:"priority"` - Scope hamodel.ActionScopeType `json:"scope" validate:"scope"` - Action hamodel.ActionType `json:"action" validate:"action"` - Description string `json:"description"` + ID int `json:"id"` + Name string `json:"name" binding:"required"` + BkBizID int `json:"bk_biz_id" binding:"required"` + TriggerEventName haprobe.DbEventName `json:"trigger_event_name" validate:"triggerEventName"` + TriggerCount int `json:"trigger_count" validate:"triggerCount"` + Priority int `json:"priority" validate:"priority"` + Scope hamodel.ActionScopeType `json:"scope" validate:"scope"` + Action hamodel.ActionType `json:"action" validate:"action"` + Description string `json:"description"` } // StrategyCreateRequest strategy create request @@ -124,14 +123,13 @@ type StrategyBatchUpdateStatusRequest struct { // GlobalStrategyCreateRequest global strategy create request type GlobalStrategyCreateRequest struct { - Name string `json:"name" binding:"required"` - TriggerEventName haprobe.DbEventName `json:"trigger_event_name" binding:"required"` - TriggerEventNameReason haprobe.DbEventNameReason `json:"trigger_event_name_reason" validate:"triggerEventNameReason"` - TriggerCount int `json:"trigger_count" validate:"triggerCount"` - Priority int `json:"priority" validate:"priority"` - Scope hamodel.ActionScopeType `json:"scope" validate:"scope"` - Action hamodel.ActionType `json:"action" validate:"action"` - Description string `json:"description"` + Name string `json:"name" binding:"required"` + TriggerEventName haprobe.DbEventName `json:"trigger_event_name" validate:"triggerEventName"` + TriggerCount int `json:"trigger_count" validate:"triggerCount"` + Priority int `json:"priority" validate:"priority"` + Scope hamodel.ActionScopeType `json:"scope" validate:"scope"` + Action hamodel.ActionType `json:"action" validate:"action"` + Description string `json:"description"` } // GlobalStrategyListRequest global strategy list request @@ -146,14 +144,13 @@ type GlobalStrategyListRequest struct { // GlobalStrategyUpdateRequest global strategy update request type GlobalStrategyUpdateRequest struct { - Name string `json:"name" binding:"required"` - TriggerEventName haprobe.DbEventName `json:"trigger_event_name" binding:"required"` - TriggerEventNameReason haprobe.DbEventNameReason `json:"trigger_event_name_reason" validate:"triggerEventNameReason"` - TriggerCount int `json:"trigger_count" validate:"triggerCount"` - Priority int `json:"priority" validate:"priority"` - Scope hamodel.ActionScopeType `json:"scope" validate:"scope"` - Action hamodel.ActionType `json:"action" validate:"action"` - Description string `json:"description"` + Name string `json:"name" binding:"required"` + TriggerEventName haprobe.DbEventName `json:"trigger_event_name" validate:"triggerEventName"` + TriggerCount int `json:"trigger_count" validate:"triggerCount"` + Priority int `json:"priority" validate:"priority"` + Scope hamodel.ActionScopeType `json:"scope" validate:"scope"` + Action hamodel.ActionType `json:"action" validate:"action"` + Description string `json:"description"` } // GlobalStrategyStatusUpdateRequest global strategy status update request @@ -212,10 +209,10 @@ func BatchUpdateCheckDuplicatedName(s *strategy.Strategy, bkBizID int, names []s return false, nil } -// CheckTriggerEventNameReason check trigger_event_name_reason -func CheckTriggerEventNameReason(fl validator.FieldLevel) bool { - value := fl.Field().Int() - if value < 0 || value > 4 { +// CheckTriggerEventName check trigger_event_name +func CheckTriggerEventName(fl validator.FieldLevel) bool { + value := fl.Field().String() + if _, ok := haprobe.DbEventNameMap[haprobe.DbEventName(value)]; !ok { return false } return true @@ -267,7 +264,7 @@ func CheckStatus(fl validator.FieldLevel) bool { } func init() { - hanet.AddValidation("triggerEventNameReason", CheckTriggerEventNameReason, "must be between 0 and 4") + hanet.AddValidation("triggerEventName", CheckTriggerEventName, "event name is invalid") hanet.AddValidation("triggerCount", CheckTriggerCount, "must be greater than 0") hanet.AddValidation("priority", CheckPriority, "must be greater than or equal to 0") hanet.AddValidation("scope", CheckScope, "must be one of cluster, host") diff --git a/dbm-services/common/dbha-v2/internal/admin/strategy/strategy.go b/dbm-services/common/dbha-v2/internal/admin/strategy/strategy.go index fbe07925d9..c5a179bd5c 100644 --- a/dbm-services/common/dbha-v2/internal/admin/strategy/strategy.go +++ b/dbm-services/common/dbha-v2/internal/admin/strategy/strategy.go @@ -170,7 +170,6 @@ func (s *Strategy) UpdateStrategy(strategy *hamodel.DbSwitchingStrategy) error { Not(statusCond, hamodel.StatusTypeDeleted).Select( hamodel.DbSwitchingStrategyFieldName, hamodel.DbSwitchingStrategyFieldTriggerEventName, - hamodel.DbSwitchingStrategyFieldTriggerEventNameReason, hamodel.DbSwitchingStrategyFieldTriggerCount, hamodel.DbSwitchingStrategyFieldPriority, hamodel.DbSwitchingStrategyFieldScope, @@ -232,7 +231,6 @@ func (s *Strategy) BatchUpdateStrategy(strategies []*hamodel.DbSwitchingStrategy Select( hamodel.DbSwitchingStrategyFieldName, hamodel.DbSwitchingStrategyFieldTriggerEventName, - hamodel.DbSwitchingStrategyFieldTriggerEventNameReason, hamodel.DbSwitchingStrategyFieldTriggerCount, hamodel.DbSwitchingStrategyFieldPriority, hamodel.DbSwitchingStrategyFieldScope, diff --git a/dbm-services/common/dbha-v2/pkg/storage/haprobe/db_event.go b/dbm-services/common/dbha-v2/pkg/storage/haprobe/db_event.go index d9d97c6352..eff2ec23c7 100644 --- a/dbm-services/common/dbha-v2/pkg/storage/haprobe/db_event.go +++ b/dbm-services/common/dbha-v2/pkg/storage/haprobe/db_event.go @@ -69,7 +69,21 @@ const ( DbEventNameProbeOffline DbEventName = "dbha_probe_offline" ) -// DbEventNameReason db event name reason +// DbEventNameMap db event name map +var DbEventNameMap = map[DbEventName]DbEventName{ + DbEventNameDetectFailure: DbEventNameDetectFailure, + DbEventNameDetectSSHFailure: DbEventNameDetectSSHFailure, + DbEventNameProbeOffline: DbEventNameProbeOffline, +} + +// DbEventNameList db event name list +var DbEventNameList = []DbEventName{ + DbEventNameDetectFailure, + DbEventNameDetectSSHFailure, + DbEventNameProbeOffline, +} + +// DbEventNameReasonStr db event name reason type DbEventNameReasonStr string func (v DbEventNameReasonStr) String() string {