Documentation
¶
Index ¶
- Constants
- func AdapterSend(ctx context.Context, adapterType string, adapterConfig json.RawMessage, ...) error
- func ClearRuleState(ruleId int)
- func MaskPhoneNumber(number string) string
- func OnOutboxTerminal(row *models.OutboxDelivery, status string, errorMsg string)
- func RegisterPageOpener(opener PageOpener)
- func StartEvaluator(ctx context.Context)
- func ValidateOutboundURL(raw string) error
- type Adapter
- type EmailAdapter
- type EvalResult
- type ExceptionDetails
- type GitHubAdapter
- type Message
- type PageOpener
- type PushoverAdapter
- type RuleEvaluator
- type Severity
- type SlackAdapter
- type SmsAdapter
- type TelegramAdapter
- type WebhookAdapter
Constants ¶
const ( SeverityInfo = models.NotificationSeverityInfo SeverityWarning = models.NotificationSeverityWarning SeverityCritical = models.NotificationSeverityCritical )
Variables ¶
This section is empty.
Functions ¶
func AdapterSend ¶ added in v1.9.10
func AdapterSend(ctx context.Context, adapterType string, adapterConfig json.RawMessage, msg models.NotificationMessage) error
AdapterSend is the outbox's registered sender: one attempt through the channel adapter built from the persisted config snapshot.
func ClearRuleState ¶ added in v1.8.1
func ClearRuleState(ruleId int)
func MaskPhoneNumber ¶ added in v1.9.10
MaskPhoneNumber keeps only the last 4 digits, so a number can be shown in logs, errors and delivery records without disclosing it.
func OnOutboxTerminal ¶ added in v1.9.10
func OnOutboxTerminal(row *models.OutboxDelivery, status string, errorMsg string)
OnOutboxTerminal records the fired_notifications audit row for rule deliveries once their outcome is final (fired_notifications is append-only telemetry, so it must record the final truth). Page deliveries are logged in page_notifications instead, mirrored by the drain worker.
func RegisterPageOpener ¶ added in v1.9.10
func RegisterPageOpener(opener PageOpener)
func StartEvaluator ¶
func ValidateOutboundURL ¶ added in v1.9.10
ValidateOutboundURL rejects a destination on the server's own network, unless ALLOW_PRIVATE_NOTIFICATION_TARGETS is set. It guards self-scoped surfaces (personal contact methods); project webhook channels are deliberately not guarded.
Types ¶
type Adapter ¶
type Adapter interface {
Type() string
Send(ctx context.Context, msg Message) error
Validate() error
}
func NewAdapter ¶
func NewAdapter(channelType string, configJSON json.RawMessage) (Adapter, error)
type EmailAdapter ¶
type EmailAdapter struct {
Recipients []string `json:"recipients"`
}
func (*EmailAdapter) Type ¶
func (a *EmailAdapter) Type() string
func (*EmailAdapter) Validate ¶
func (a *EmailAdapter) Validate() error
type EvalResult ¶
type ExceptionDetails ¶
type GitHubAdapter ¶
type GitHubAdapter struct {
Token string `json:"token"`
Owner string `json:"owner"`
Repo string `json:"repo"`
Labels []string `json:"labels,omitempty"`
}
func (*GitHubAdapter) Type ¶
func (a *GitHubAdapter) Type() string
func (*GitHubAdapter) Validate ¶
func (a *GitHubAdapter) Validate() error
type Message ¶
type Message = models.NotificationMessage
type PageOpener ¶ added in v1.9.10
type PageOpener func(channelConfig json.RawMessage, rule *models.NotificationRuleWithChannel, msg Message) (opened bool, err error)
PageOpener opens an on-call page for a rule that targets an escalation channel, reporting whether a new page was opened (false = deduped into one already unresolved). It is implemented by the oncall package and registered from cmd/run.go; the indirection exists because notifications cannot import oncall (oncall imports this package for Message and the adapters).
type PushoverAdapter ¶ added in v1.7.22
type PushoverAdapter struct {
UserKey string `json:"userKey"`
AppToken string `json:"appToken"`
Device string `json:"device,omitempty"`
Priority int `json:"priority,omitempty"`
Retry int `json:"retry,omitempty"`
Expire int `json:"expire,omitempty"`
Sound string `json:"sound,omitempty"`
TTL int `json:"ttl,omitempty"`
HTML bool `json:"html,omitempty"`
Callback string `json:"callback,omitempty"`
}
func (*PushoverAdapter) Send ¶ added in v1.7.22
func (a *PushoverAdapter) Send(ctx context.Context, msg Message) error
func (*PushoverAdapter) Type ¶ added in v1.7.22
func (a *PushoverAdapter) Type() string
func (*PushoverAdapter) Validate ¶ added in v1.7.22
func (a *PushoverAdapter) Validate() error
type RuleEvaluator ¶
type RuleEvaluator func(ctx context.Context, rule *models.NotificationRule, projectId uuid.UUID) (*EvalResult, error)
type Severity ¶
type Severity = models.NotificationSeverity
Message and Severity live in models (as NotificationMessage / NotificationSeverity) so the outbox package can persist them without importing this package; the aliases keep every call site unchanged.
type SlackAdapter ¶
type SlackAdapter struct {
WebhookURL string `json:"webhookUrl"`
Channel string `json:"channel,omitempty"`
Username string `json:"username,omitempty"`
}
func (*SlackAdapter) Type ¶
func (a *SlackAdapter) Type() string
func (*SlackAdapter) Validate ¶
func (a *SlackAdapter) Validate() error
type SmsAdapter ¶ added in v1.9.10
type SmsAdapter struct {
PhoneNumber string `json:"phoneNumber"`
}
SmsAdapter delivers via the Twilio Messages API. Without Twilio credentials SMS is not offered at all (contact-method creation is rejected and the escalator skips SMS methods), so Send only has to fail loudly for deliveries already queued when the credentials were removed.
func (*SmsAdapter) Send ¶ added in v1.9.10
func (a *SmsAdapter) Send(ctx context.Context, msg Message) error
func (*SmsAdapter) Type ¶ added in v1.9.10
func (a *SmsAdapter) Type() string
func (*SmsAdapter) Validate ¶ added in v1.9.10
func (a *SmsAdapter) Validate() error
type TelegramAdapter ¶ added in v1.7.24
func (*TelegramAdapter) Send ¶ added in v1.7.24
func (a *TelegramAdapter) Send(ctx context.Context, msg Message) error
func (*TelegramAdapter) Type ¶ added in v1.7.24
func (a *TelegramAdapter) Type() string
func (*TelegramAdapter) Validate ¶ added in v1.7.24
func (a *TelegramAdapter) Validate() error
type WebhookAdapter ¶
type WebhookAdapter struct {
URL string `json:"url"`
Method string `json:"method,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
Secret string `json:"secret,omitempty"`
}
func (*WebhookAdapter) Type ¶
func (a *WebhookAdapter) Type() string
func (*WebhookAdapter) Validate ¶
func (a *WebhookAdapter) Validate() error
Source Files
¶
- adapter_email.go
- adapter_github.go
- adapter_pushover.go
- adapter_slack.go
- adapter_sms.go
- adapter_telegram.go
- adapter_webhook.go
- adapters.go
- cooldown.go
- dispatch.go
- egress.go
- evaluator.go
- evaluator_event_sqlite.go
- evaluator_helpers.go
- evaluator_polled_sqlite.go
- impact_shared.go
- messages.go
- outbox_hooks.go
- page_opener.go
- task_failure_shared.go