Documentation
¶
Index ¶
- Constants
- func AlwaysNotifiable(_ recipient.Key) bool
- type ContactChannelPair
- type ContactChannels
- type Escalation
- func (e *Escalation) DisplayName() string
- func (e *Escalation) Eval(filterable *EscalationFilter) (bool, error)
- func (e *Escalation) GetContactsAt(t time.Time) []ContactChannelPair
- func (e *Escalation) IncrementalInitAndValidate() error
- func (e *Escalation) MarshalLogObject(encoder zapcore.ObjectEncoder) error
- func (e *Escalation) TableName() string
- type EscalationFilter
- func (e *EscalationFilter) EvalEqual(key string, value string) (bool, error)
- func (e *EscalationFilter) EvalExists(key string) bool
- func (e *EscalationFilter) EvalLess(key string, value string) (bool, error)
- func (e *EscalationFilter) EvalLessOrEqual(key string, value string) (bool, error)
- func (e *EscalationFilter) EvalLike(key string, value string) (bool, error)
- func (e *EscalationFilter) ReevaluateAfter(escalationCond filter.Filter) time.Duration
- type EscalationRecipient
- type Rule
Constants ¶
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 ¶
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 ContactChannels ¶
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 { baseconf.IncrementalPkDbEntry[int64] `db:",inline"` 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 `db:"-"` Recipients []*EscalationRecipient `db:"-"` }
func (*Escalation) DisplayName ¶
func (e *Escalation) DisplayName() string
func (*Escalation) Eval ¶
func (e *Escalation) Eval(filterable *EscalationFilter) (bool, error)
Eval evaluates the configured escalation filter for the provided filter. Returns always true if there are no configured escalation conditions.
func (*Escalation) GetContactsAt ¶
func (e *Escalation) GetContactsAt(t time.Time) []ContactChannelPair
func (*Escalation) IncrementalInitAndValidate ¶
func (e *Escalation) IncrementalInitAndValidate() error
IncrementalInitAndValidate implements the config.IncrementalConfigurableInitAndValidatable interface.
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.go.dev/go.uber.org/zap/zapcore#ObjectMarshaler
func (*Escalation) TableName ¶
func (e *Escalation) TableName() string
type EscalationFilter ¶
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 { baseconf.IncrementalPkDbEntry[int64] `db:",inline"` EscalationID int64 `db:"rule_escalation_id"` ChannelID sql.NullInt64 `db:"channel_id"` recipient.Key `db:",inline"` Recipient recipient.Recipient `db:"-"` }
func (*EscalationRecipient) MarshalLogObject ¶
func (r *EscalationRecipient) MarshalLogObject(encoder zapcore.ObjectEncoder) error
MarshalLogObject implements the zapcore.ObjectMarshaler interface.
func (*EscalationRecipient) TableName ¶
func (r *EscalationRecipient) TableName() string
type Rule ¶
type Rule struct { baseconf.IncrementalPkDbEntry[int64] `db:",inline"` Name string `db:"name"` TimePeriod *timeperiod.TimePeriod `db:"-"` TimePeriodID types.Int `db:"timeperiod_id"` ObjectFilter filter.Filter `db:"-"` ObjectFilterExpr types.String `db:"object_filter"` Escalations map[int64]*Escalation `db:"-"` }
func (*Rule) Eval ¶
func (r *Rule) Eval(filterable filter.Filterable) (bool, error)
Eval evaluates the configured object filter for the provided filterable. Returns always true if the current rule doesn't have a configured object filter.
func (*Rule) IncrementalInitAndValidate ¶
IncrementalInitAndValidate implements the config.IncrementalConfigurableInitAndValidatable interface.
func (*Rule) MarshalLogObject ¶
func (r *Rule) MarshalLogObject(encoder zapcore.ObjectEncoder) error
MarshalLogObject implements the zapcore.ObjectMarshaler interface.