package executor import ( "fmt" "regexp" "strings" schemepkg "git.buran.team/main/cep/scheme" ) type MatchProcessor struct { expression *regexp.Regexp count int } func NewMatchProcessor(processorScheme schemepkg.Processor) (*MatchProcessor, error) { e, err := regexp.Compile(processorScheme.KindMatch.Expression) if err != nil { return nil, fmt.Errorf("can't create match processor: %w", err) } return &MatchProcessor{ expression: e, count: processorScheme.KindMatch.Count, }, nil } func (this *MatchProcessor) Process(buffer []byte) bool { lines := strings.Split(string(buffer), "\n") count := 0 for _, line := range lines { if !this.expression.Match([]byte(line)) { continue } count += 1 } if this.count == -1 { return count > 0 } return count == this.count }