rule

package
v0.0.0-...-17a0abe Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: GPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const RetryNever = time.Duration(math.MaxInt64)

RetryNever indicates that an escalation condition should never be retried once it has been evaluated.

Variables

This section is empty.

Functions

func AlwaysNotifiable

func AlwaysNotifiable(_ recipient.Key) bool

AlwaysNotifiable (checks) whether the given recipient is notifiable and returns always true. This function is usually passed as an argument to ContactChannels.LoadFromEscalationRecipients whenever you do not want to perform any custom actions.

Types

type ContactChannelPair

type ContactChannelPair struct {
	Contact   *recipient.Contact
	ChannelID sql.NullInt64
}

type ContactChannels

type ContactChannels map[*recipient.Contact]map[int64]bool

ContactChannels stores a set of channel IDs for each set of individual contacts.

func (ContactChannels) LoadFromEscalationRecipients

func (ch ContactChannels) LoadFromEscalationRecipients(escalation *Escalation, t time.Time, isNotifiable func(recipient.Key) bool)

LoadFromEscalationRecipients loads recipients channel of the specified escalation to the current map. You can provide this method a callback to control whether the channel of a specific contact should be loaded, and it will skip those for whom the callback returns false. Pass AlwaysNotifiable for default actions.

func (ContactChannels) LoadRecipientChannel

func (ch ContactChannels) LoadRecipientChannel(er *EscalationRecipient, t time.Time, isNotifiable func(recipient.Key) bool)

LoadRecipientChannel loads recipient channel to the current map. You can provide this method a callback to control whether the channel of a specific contact should be loaded, and it will skip those for whom the callback returns false. Pass AlwaysNotifiable for default actions.

type Escalation

type Escalation struct {
	ID            int64          `db:"id"`
	RuleID        int64          `db:"rule_id"`
	NameRaw       sql.NullString `db:"name"`
	Condition     filter.Filter  `db:"-"`
	ConditionExpr sql.NullString `db:"condition"`
	FallbackForID sql.NullInt64  `db:"fallback_for"`
	Fallbacks     []*Escalation

	Recipients []*EscalationRecipient
}

func (*Escalation) DisplayName

func (e *Escalation) DisplayName() string

func (*Escalation) GetContactsAt

func (e *Escalation) GetContactsAt(t time.Time) []ContactChannelPair

func (*Escalation) MarshalLogObject

func (e *Escalation) MarshalLogObject(encoder zapcore.ObjectEncoder) error

MarshalLogObject implements the zapcore.ObjectMarshaler interface.

This allows us to use `zap.Inline(escalation)` or `zap.Object("rule_escalation", escalation)` wherever fine-grained logging context is needed, without having to add all the individual fields ourselves each time. https://pkg.golang.ir/go.uber.org/zap/zapcore#ObjectMarshaler

func (*Escalation) TableName

func (e *Escalation) TableName() string

type EscalationFilter

type EscalationFilter struct {
	IncidentAge      time.Duration
	IncidentSeverity event.Severity
}

func (*EscalationFilter) EvalEqual

func (e *EscalationFilter) EvalEqual(key string, value string) (bool, error)

func (*EscalationFilter) EvalExists

func (e *EscalationFilter) EvalExists(key string) bool

func (*EscalationFilter) EvalLess

func (e *EscalationFilter) EvalLess(key string, value string) (bool, error)

func (*EscalationFilter) EvalLessOrEqual

func (e *EscalationFilter) EvalLessOrEqual(key string, value string) (bool, error)

func (*EscalationFilter) EvalLike

func (e *EscalationFilter) EvalLike(key string, value string) (bool, error)

func (*EscalationFilter) ReevaluateAfter

func (e *EscalationFilter) ReevaluateAfter(escalationCond filter.Filter) time.Duration

ReevaluateAfter returns the duration after which escalationCond should be reevaluated the next time on the incident represented by e.

escalationCond must correspond to an escalation that did not trigger on the incident represented by e before. If nothing in the incident changes apart from time passing by, the escalation is guaranteed to not trigger within the returned duration. After that duration, the escalation should be reevaluated, and it may or may not trigger. If anything else changes, for example due to an external event, the escalation must be reevaluated as well.

type EscalationRecipient

type EscalationRecipient struct {
	ID            int64         `db:"id"`
	EscalationID  int64         `db:"rule_escalation_id"`
	ChannelID     sql.NullInt64 `db:"channel_id"`
	recipient.Key `db:",inline"`
	Recipient     recipient.Recipient
}

func (*EscalationRecipient) TableName

func (r *EscalationRecipient) TableName() string

type Rule

type Rule struct {
	ID               int64      `db:"id"`
	IsActive         types.Bool `db:"is_active"`
	Name             string     `db:"name"`
	TimePeriod       *timeperiod.TimePeriod
	TimePeriodID     types.Int     `db:"timeperiod_id"`
	ObjectFilter     filter.Filter `db:"-"`
	ObjectFilterExpr types.String  `db:"object_filter"`
	Escalations      map[int64]*Escalation
}

Jump to

Keyboard shortcuts

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