40 lines
771 B
Go
40 lines
771 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
|
|
"gopkg.in/yaml.v2"
|
|
)
|
|
|
|
type DerivedRule struct {
|
|
ParentCode int `yaml:"parentCode"`
|
|
ChildCode int `yaml:"childCode"`
|
|
}
|
|
type RelatedRule struct {
|
|
Codes []int `yaml:"codes"`
|
|
NeType string `yaml:"neType"`
|
|
TimeWindow int `yaml:"timeWindow"`
|
|
}
|
|
type AlarmRelationRules struct {
|
|
Derived []DerivedRule `yaml:"derived"`
|
|
Related []RelatedRule `yaml:"related"`
|
|
}
|
|
|
|
var RelationRules AlarmRelationRules
|
|
|
|
func LoadAlarmRelationRules(path string) error {
|
|
data, err := os.ReadFile(path)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return yaml.Unmarshal(data, &RelationRules)
|
|
}
|
|
|
|
func LoadNbiRelationRulesConfig(path string) error {
|
|
data, err := os.ReadFile(path)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return yaml.Unmarshal(data, &RelationRules)
|
|
}
|