filter

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2019 License: BSD-2-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type All

type All []Filter

All matchers match like a conjunctive normal form.

Each filter is evaluated using filter.Any, if all filters match, the filter set matches.

func (All) Match

func (a All) Match(n event.Notification) bool

Match implementation.

type Any

type Any []Filter

Any matcher matches like a disjunctive normal form.

Each filter is evaluated using filter.All, if any filter matches, the filter set matches.

func (Any) Match

func (a Any) Match(n event.Notification) bool

Match implementation.

type Filter

type Filter struct {
	Host             string                 `json:",omitempty"`
	Service          string                 `json:",omitempty"`
	Users            []string               `json:",omitempty"`
	Author           string                 `json:",omitempty"`
	Text             string                 `json:",omitempty"`
	NotificationType event.NotificationType `json:"notification_type,omitempty"`
}

Filter usable as filter.

func (Filter) All

func (f Filter) All(x event.Notification) bool

All returns true if all values of the receiver are contained in x. Values not set in the receiver aren't considered. The comparison is shallow, contents of CheckResult aren't considered.

func (Filter) Any

func (f Filter) Any(x event.Notification) bool

Any returns true if one of the values of the receiver is contained in x. Values not set in the receiver aren't considered. The comparison is shallow, contents of CheckResult aren't considered.

type Matcher

type Matcher interface {
	// Match the event according to the rules of the filter set.
	// Returns true on match, false otherwise.
	Match(n event.Notification) bool
}

Matcher implements rules for matching sets of filters.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL