Documentation ¶
Index ¶
- func ErrChannelNotFound(ch string) error
- func ErrChannelTypeNotSupported(chType string) error
- func MustInitFromViper()
- type Channel
- type ChannelType
- type DingTalkChannel
- type DingTalkConfig
- type DingTalkMarkdownFormatter
- type Formatter
- type Manager
- type Notification
- type Severity
- type SimpleTextFormatter
- type SmtpChannel
- type SmtpConfig
- type SmtpHtmlFormatter
- type TelegramChannel
- type TelegramConfig
- type TelegramMarkdownFormatter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrChannelNotFound ¶ added in v0.2.1
func ErrChannelTypeNotSupported ¶ added in v0.2.1
func MustInitFromViper ¶
func MustInitFromViper()
MustInitFromViper inits alert from viper settings or panic on error.
Types ¶
type Channel ¶ added in v0.2.1
type Channel interface { Name() string Type() ChannelType Send(context.Context, *Notification) error }
Notification channel interface.
type ChannelType ¶ added in v0.2.1
type ChannelType string
Notification channel type.
const ( ChannelTypeDingTalk ChannelType = "dingtalk" ChannelTypeTelegram ChannelType = "telegram" ChannelTypeSMTP ChannelType = "smtp" )
type DingTalkChannel ¶ added in v0.2.1
type DingTalkChannel struct { Formatter Formatter // message formatter ID string // channel id Config DingTalkConfig // channel config // contains filtered or unexported fields }
DingTalkChannel DingTalk notification channel
func NewDingTalkChannel ¶ added in v0.2.1
func NewDingTalkChannel(chID string, fmt Formatter, conf DingTalkConfig) *DingTalkChannel
func (*DingTalkChannel) Name ¶ added in v0.2.1
func (dtc *DingTalkChannel) Name() string
func (*DingTalkChannel) Send ¶ added in v0.2.1
func (dtc *DingTalkChannel) Send(ctx context.Context, note *Notification) error
func (*DingTalkChannel) Type ¶ added in v0.2.1
func (dtc *DingTalkChannel) Type() ChannelType
type DingTalkConfig ¶
type DingTalkMarkdownFormatter ¶ added in v0.2.1
type DingTalkMarkdownFormatter struct {
// contains filtered or unexported fields
}
func NewDingtalkMarkdownFormatter ¶ added in v0.2.1
func NewDingtalkMarkdownFormatter(tags []string) (*DingTalkMarkdownFormatter, error)
func (DingTalkMarkdownFormatter) Format ¶ added in v0.2.1
func (f DingTalkMarkdownFormatter) Format(note *Notification) (string, error)
type Formatter ¶ added in v0.2.1
type Formatter interface {
Format(note *Notification) (string, error)
}
Formatter defines how messages are formatted.
type Manager ¶ added in v0.2.1
type Manager struct {
// contains filtered or unexported fields
}
func DefaultManager ¶ added in v0.2.1
func DefaultManager() *Manager
func NewManager ¶ added in v0.2.1
func NewManager() *Manager
type Notification ¶ added in v0.2.1
type Notification struct { Title string // message title Content interface{} // message content Severity Severity // severity level }
Notification represents core information for an alert.
type SimpleTextFormatter ¶ added in v0.2.1
type SimpleTextFormatter struct {
// contains filtered or unexported fields
}
func NewSimpleTextFormatter ¶ added in v0.2.1
func NewSimpleTextFormatter(tags []string) *SimpleTextFormatter
func (*SimpleTextFormatter) Format ¶ added in v0.2.1
func (f *SimpleTextFormatter) Format(note *Notification) (string, error)
type SmtpChannel ¶ added in v0.2.1
type SmtpChannel struct { Formatter Formatter // Formatter is used to format the notification message ID string // ID is the identifier of the channel Config SmtpConfig // Config contains the configuration for the SMTP server }
SmtpChannel represents a SMTP email notification channel
func NewSmtpChannel ¶ added in v0.2.1
func NewSmtpChannel(chID string, fmtter Formatter, conf SmtpConfig) *SmtpChannel
NewSmtpChannel creates a new SMTP channel with the given ID, formatter, and configuration
func (*SmtpChannel) Name ¶ added in v0.2.1
func (c *SmtpChannel) Name() string
Name returns the ID of the channel
func (*SmtpChannel) Send ¶ added in v0.2.1
func (c *SmtpChannel) Send(ctx context.Context, note *Notification) error
Send sends a notification using the SMTP channel
func (*SmtpChannel) Type ¶ added in v0.2.1
func (c *SmtpChannel) Type() ChannelType
Type returns the type of the channel, which is SMTP
type SmtpConfig ¶ added in v0.2.1
type SmtpHtmlFormatter ¶ added in v0.2.1
type SmtpHtmlFormatter struct {
// contains filtered or unexported fields
}
func NewSmtpHtmlFormatter ¶ added in v0.2.1
func NewSmtpHtmlFormatter( conf SmtpConfig, tags []string) (f *SmtpHtmlFormatter, err error)
func (*SmtpHtmlFormatter) Format ¶ added in v0.2.1
func (f *SmtpHtmlFormatter) Format(note *Notification) (msg string, err error)
type TelegramChannel ¶ added in v0.2.1
type TelegramChannel struct { Formatter Formatter // message formatter ID string // channel id Config TelegramConfig // channel config // contains filtered or unexported fields }
TelegramChannel Telegram notification channel
func NewTelegramChannel ¶ added in v0.2.1
func NewTelegramChannel(chID string, fmt Formatter, conf TelegramConfig) (*TelegramChannel, error)
func (*TelegramChannel) Name ¶ added in v0.2.1
func (tc *TelegramChannel) Name() string
func (*TelegramChannel) Send ¶ added in v0.2.1
func (tc *TelegramChannel) Send(ctx context.Context, note *Notification) error
func (*TelegramChannel) Type ¶ added in v0.2.1
func (tc *TelegramChannel) Type() ChannelType
type TelegramConfig ¶ added in v0.2.1
type TelegramMarkdownFormatter ¶ added in v0.2.1
type TelegramMarkdownFormatter struct {
// contains filtered or unexported fields
}
func NewTelegramMarkdownFormatter ¶ added in v0.2.1
func NewTelegramMarkdownFormatter(tags []string) (f *TelegramMarkdownFormatter, err error)
func (TelegramMarkdownFormatter) Format ¶ added in v0.2.1
func (f TelegramMarkdownFormatter) Format(note *Notification) (string, error)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.