modelRT/alert/event_options.go

40 lines
827 B
Go

// Package alert define alert event struct of modelRT project
package alert
// EventOption 定义选项函数的类型
type EventOption func(*EventRecord)
// WithCondition 设置事件场景描述
func WithCondition(cond map[string]any) EventOption {
return func(e *EventRecord) {
if cond != nil {
e.Condition = cond
}
}
}
// WithSubscriptions 设置订阅信息
func WithSubscriptions(subs []any) EventOption {
return func(e *EventRecord) {
if subs != nil {
e.AttachedSubscriptions = subs
}
}
}
// WithOperations 设置操作记录
func WithOperations(ops []OperationRecord) EventOption {
return func(e *EventRecord) {
if ops != nil {
e.Operations = ops
}
}
}
// WithCategory 设置可选分类
func WithCategory(cat string) EventOption {
return func(e *EventRecord) {
e.Category = cat
}
}