Documentation
¶
Index ¶
- func AllowedVersions() []string
- func CompareValidationResult(result1, result2 ValidationResult) bool
- func EmptyActionImpl(_ map[string]interface{}) error
- func NewEnv() (*cel.Env, error)
- func ValidateApiRule(apiRule *resources.DiagnosisRule, actionImpls map[string]ActionImpl) ([]*Rule, ValidationResult)
- func ValidateRuleSpecStr(apiRuleStr string) ([]*Rule, ValidationResult)
- type Action
- type ActionImpl
- type Condition
- type ErrorSection
- type Rule
- type RuleItem
- type ValidationError
- type ValidationErrorLocation
- type ValidationErrorUnexpectedVersion
- type ValidationResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllowedVersions ¶
func AllowedVersions() []string
func CompareValidationResult ¶
func CompareValidationResult(result1, result2 ValidationResult) bool
func EmptyActionImpl ¶
func ValidateApiRule ¶
func ValidateApiRule(apiRule *resources.DiagnosisRule, actionImpls map[string]ActionImpl) ([]*Rule, ValidationResult)
ValidateApiRule validates an API rule and returns a list of rules and validation result.
func ValidateRuleSpecStr ¶
func ValidateRuleSpecStr(apiRuleStr string) ([]*Rule, ValidationResult)
Types ¶
type Action ¶
type Action struct { Name string RawKwargs map[string]interface{} // contains filtered or unexported fields }
Action represents an action with a name and parameters.
func NewAction ¶
func NewAction( name string, rawKwargs map[string]interface{}, impl ActionImpl, ) (*Action, error)
NewAction creates a new action with compiled CEL expressions.
func (*Action) Run ¶
Run executes the action with the given activation context as well as additional kwargs. Note that it's user's responsibility to ensure that the additional kwargs do not conflict with fixed kwargs.
type ActionImpl ¶
ActionImpl is the alias for the action implementation function type.
type Condition ¶
type Condition struct { Raw string // contains filtered or unexported fields }
Condition represents a CEL condition.
func NewCondition ¶
NewCondition creates and validates a new condition.
type ErrorSection ¶
type ErrorSection int
ErrorSection represents the section where validation error occurred.
const ( ConditionSection ErrorSection = iota + 1 ActionSection )
type Rule ¶
type Rule struct { Conditions []Condition Actions []Action Scope map[string]string Topics mapset.Set[string] DebounceTime time.Duration Metadata map[string]interface{} }
Rule represents a rule with conditions and actions.
type RuleItem ¶
type RuleItem struct { Msg map[string]interface{} `json:"msg"` Topic string `json:"topic"` Ts float64 `json:"ts"` // Timestamp in seconds MsgType string `json:"msgType"` Source string `json:"source"` // filepath or topic of the message }
RuleItem represents an item to be evaluated by the rule engine.
type ValidationError ¶
type ValidationError struct { Location *ValidationErrorLocation `json:"location,omitempty"` UnexpectedVersion *ValidationErrorUnexpectedVersion `json:"unexpectedVersion,omitempty"` SyntaxError *struct{} `json:"syntaxError,omitempty"` EmptySection *struct{} `json:"emptySection,omitempty"` }
ValidationError represents a validation error.
func (ValidationError) Equal ¶
func (e ValidationError) Equal(other ValidationError) bool
Equal Add this helper method to make ValidationError comparable.
type ValidationErrorLocation ¶
type ValidationErrorLocation struct { Section ErrorSection `json:"section"` ItemIndex int `json:"itemIndex,omitempty"` }
ValidationErrorLocation represents where the validation error occurred.
func (ValidationErrorLocation) Equal ¶
func (l ValidationErrorLocation) Equal(other ValidationErrorLocation) bool
Equal Add this helper method for ValidationErrorLocation.
type ValidationErrorUnexpectedVersion ¶
type ValidationErrorUnexpectedVersion struct {
AllowedVersions []string `json:"allowedVersions"`
}
ValidationErrorUnexpectedVersion represents version validation error.
type ValidationResult ¶
type ValidationResult struct { Success bool `json:"success"` Errors []ValidationError `json:"errors"` }
ValidationResult represents the result of validation.