// MatchesOne returns true if the matcher matches at least one item in the TagSet func (m Matcher) MatchesOne(t *event.TagSet) (matches bool) { m.ForEach(func(k string, v *regexp.Regexp) { if v.MatchString(t.Get(k)) { matches = true return } }) return }
// MatchesAll returns true if the TagSet satisfies the entire matcher func (m *Matcher) MatchesAll(t *event.TagSet) (matches bool) { matches = true m.ForEach(func(k string, v *regexp.Regexp) { if !v.MatchString(t.Get(k)) { matches = false } }) return }
func MatcherFromTagSet(t *event.TagSet) (Matcher, error) { m := make(Matcher, len(*t)) i := 0 var verr error t.ForEach(func(k, v string) { match, err := regexp.Compile(v) if err != nil { verr = err } else { m[i] = MatchSet{ Key: k, Value: match, } } }) return m, verr }