github.com/alibaba/ilogtail/pkg@v0.0.0-20250526110833-c53b480d046c/helper/eventrecorder/event_define.go (about) 1 // Copyright 2021 iLogtail Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package eventrecorder 16 17 import "fmt" 18 19 const ProductCode = "SLS" 20 21 const ( 22 LogController string = "LogController" 23 Logtail string = "Logtail" 24 ) 25 26 type EventDefine struct { 27 currentModule string 28 } 29 30 type Action string 31 32 const ( 33 CreateConfig Action = "CreateConfig" 34 35 CreateConfigStatus Action = "CreateConfigStatus" 36 37 UpdateConfig Action = "UpdateConfig" 38 39 UpdateConfigStatus Action = "UpdateConfigStatus" 40 41 DeleteConfig Action = "DeleteConfig" 42 43 CreateProject Action = "CreateProject" 44 45 CreateLogstore Action = "CreateLogstore" 46 47 CreateTag Action = "CreateTag" 48 49 CreateIndex Action = "CreateIndex" 50 51 CreateProductLogStore Action = "CreateProductLogstore" 52 53 CreateProductApp Action = "CreateProductApp" 54 ) 55 56 type Alarm string 57 58 const ( 59 CommonAlarm Alarm = "Fail" 60 ) 61 62 func NewEventDefine(moduleCode string) *EventDefine { 63 eventDefine := &EventDefine{} 64 eventDefine.currentModule = moduleCode 65 return eventDefine 66 } 67 68 func (e *EventDefine) getErrorAction(action Action, alarm Alarm) string { 69 return fmt.Sprintf("%s.%s.%s.%s", ProductCode, e.currentModule, action, alarm) 70 } 71 72 func (e *EventDefine) getInfoAction(action Action) string { 73 return fmt.Sprintf("%s.%s.%s.%s", ProductCode, e.currentModule, action, "Success") 74 }