matcher

package
v0.0.0-...-a2946bf Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InvalidReturnVal = errors.New("invalid return value: must be a bool value")

InvalidReturnVal is a error represents the expression return value is invalid

Functions

This section is empty.

Types

type EventFinger

type EventFinger struct {
	// contains filtered or unexported fields
}

EventFinger Event 指纹

func NewEventFinger

func NewEventFinger(fingerExpr string) (*EventFinger, error)

NewEventFinger create a new EventFinger instance

func (*EventFinger) Run

func (m *EventFinger) Run(msg repository.Event) (string, error)

Run 根据指定的表达式创建 Event 的指纹

type EventMatcher

type EventMatcher struct {
	// contains filtered or unexported fields
}

EventMatcher is a matcher for repository.Event

func NewEventMatcher

func NewEventMatcher(rule repository.Rule) (*EventMatcher, error)

NewEventMatcher create a new EventMatcher https://github.com/antonmedv/expr/blob/master/docs/Language-Definition.md

func (*EventMatcher) Match

func (m *EventMatcher) Match(evt repository.Event) (matched bool, ignored bool, err error)

Match check whether the msg is match with the rule

func (*EventMatcher) Rule

func (m *EventMatcher) Rule() repository.Rule

Rule return original rule object

type EventWrap

type EventWrap struct {
	repository.Event
	helper.Helpers
	// contains filtered or unexported fields
}

EventWrap is a wrapper to repository.Event We will add some helper function to message

func NewEventWrap

func NewEventWrap(message repository.Event) *EventWrap

func (*EventWrap) FullJSON

func (msg *EventWrap) FullJSON() string

FullJSON return whole event as json document

func (*EventWrap) IsPlain

func (msg *EventWrap) IsPlain() bool

IsPlain return whether the message is a plain message

func (*EventWrap) IsRecoverable

func (msg *EventWrap) IsRecoverable() bool

IsRecoverable return whether the message is recoverable

func (*EventWrap) IsRecovery

func (msg *EventWrap) IsRecovery() bool

IsRecovery return whether the message is a recovery message

func (*EventWrap) JsonGet

func (msg *EventWrap) JsonGet(key string, defaultValue string) string

JsonGet parse message.Content as a json string and return the string value for key

type TriggerContext

type TriggerContext struct {
	helper.Helpers
	Group   repository.EventGroup
	Trigger repository.Trigger

	EventCallback func() []repository.Event
	// contains filtered or unexported fields
}

func NewTriggerContext

func NewTriggerContext(resolver infra.Resolver, trigger repository.Trigger, group repository.EventGroup, eventCallback func() []repository.Event) *TriggerContext

NewTriggerContext create a new TriggerContext

func (*TriggerContext) Events

func (tc *TriggerContext) Events() []repository.Event

Events return all events in group

func (*TriggerContext) EventsCount

func (tc *TriggerContext) EventsCount() int64

EventsCount return the count in group

func (*TriggerContext) EventsMatchRegexCount

func (tc *TriggerContext) EventsMatchRegexCount(regex string) int64

EventsMatchRegexCount get the count for events matched regex

func (*TriggerContext) EventsWithMetaCount

func (tc *TriggerContext) EventsWithMetaCount(key, value string) int64

EventsWithMetaCount get the count for events has a meta[key] equals to value

func (*TriggerContext) EventsWithTagsCount

func (tc *TriggerContext) EventsWithTagsCount(tags string) int64

EventsWithTagsCount get the count for events which has tags

func (*TriggerContext) HasEventsMatchRegex

func (tc *TriggerContext) HasEventsMatchRegex(regex string) bool

HasEventsMatchRegex check if events matched regex

func (*TriggerContext) HasEventsMatchRegexs

func (tc *TriggerContext) HasEventsMatchRegexs(regexs []string) bool

HasEventsMatchRegexs check if events matched regexs

func (*TriggerContext) LastTriggeredGroup

func (tc *TriggerContext) LastTriggeredGroup(triggerStatus string) repository.EventGroup

LastTriggeredGroup get last triggeredGroup

func (*TriggerContext) Messages

func (tc *TriggerContext) Messages() []repository.Event

Messages return all events in group This method is depressed

func (*TriggerContext) MessagesCount

func (tc *TriggerContext) MessagesCount() int64

MessagesCount return the count in group This method is depressed

func (*TriggerContext) MessagesMatchRegexCount

func (tc *TriggerContext) MessagesMatchRegexCount(regex string) int64

MessagesMatchRegexCount get the count for events matched regex This method is depressed

func (*TriggerContext) MessagesWithMetaCount

func (tc *TriggerContext) MessagesWithMetaCount(key, value string) int64

MessagesWithMetaCount get the count for events has a meta[key] equals to value This method is depressed

func (*TriggerContext) MessagesWithTagsCount

func (tc *TriggerContext) MessagesWithTagsCount(tags string) int64

MessagesWithTagsCount get the count for events which has tags This method is depressed

func (*TriggerContext) TriggeredTimesInPeriod

func (tc *TriggerContext) TriggeredTimesInPeriod(periodInMinutes int, triggerStatus string) int64

TriggeredTimesInPeriod return triggered times in specified periods

func (*TriggerContext) UsersHasProperty

func (tc *TriggerContext) UsersHasProperty(key, value, returnField string) []string

func (*TriggerContext) UsersHasPropertyRegex

func (tc *TriggerContext) UsersHasPropertyRegex(key, valueRegex, returnField string) []string

func (*TriggerContext) UsersIDWithProperty

func (tc *TriggerContext) UsersIDWithProperty(key, value, returnField string) []repository.UserIDWithMeta

func (*TriggerContext) UsersIDWithPropertyRegex

func (tc *TriggerContext) UsersIDWithPropertyRegex(key, valueRegex, returnField string) []repository.UserIDWithMeta

type TriggerMatcher

type TriggerMatcher struct {
	// contains filtered or unexported fields
}

TriggerMatcher is a matcher for trigger

func NewTriggerMatcher

func NewTriggerMatcher(condition string, trigger repository.Trigger, boolRet bool) (*TriggerMatcher, error)

NewTriggerMatcher create a new TriggerMatcher https://github.com/antonmedv/expr/blob/master/docs/Language-Definition.md

func (*TriggerMatcher) Eval

func (m *TriggerMatcher) Eval(triggerCtx *TriggerContext) ([]string, error)

Eval 根据指定的表达式创建 Event 解析内容为字符串数组

func (*TriggerMatcher) Match

func (m *TriggerMatcher) Match(triggerCtx *TriggerContext) (bool, error)

Match check whether the msg is match with the rule

func (*TriggerMatcher) Trigger

func (m *TriggerMatcher) Trigger() repository.Trigger

Trigger return original trigger object

Jump to

Keyboard shortcuts

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