Documentation
¶
Index ¶
- func ValidateConfig(notifType NotificationType, config json.RawMessage) error
- func ValidateNotificationName(name string) error
- func ValidateNotificationType(t string) error
- type EmailConfig
- type Notification
- type NotificationLog
- type NotificationStore
- func (s *NotificationStore) Create(name string, notifType NotificationType, config json.RawMessage) (*Notification, error)
- func (s *NotificationStore) Delete(name string) error
- func (s *NotificationStore) Get(name string) (*Notification, error)
- func (s *NotificationStore) GetLogs(limit int) ([]NotificationLog, error)
- func (s *NotificationStore) List() ([]Notification, error)
- func (s *NotificationStore) LogNotification(notificationName, status string, message, errorMsg *string) error
- func (s *NotificationStore) Update(name string, notifType NotificationType, config json.RawMessage) (*Notification, error)
- type NotificationType
- type SlackConfig
- type TelegramConfig
- type WebhookConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateConfig ¶
func ValidateConfig(notifType NotificationType, config json.RawMessage) error
func ValidateNotificationName ¶
ValidateNotificationName validates notification name format
Types ¶
type EmailConfig ¶
type EmailConfig struct {
Host string `json:"host" validate:"required,hostname_rfc1123|ip"`
Port int `json:"port" validate:"required,min=1,max=65535"`
Username string `json:"username" validate:"required"`
Password string `json:"password" validate:"required"`
From string `json:"from" validate:"required,email"`
To []string `json:"to" validate:"required,min=1,dive,email"`
TLS bool `json:"tls"` // Direct TLS connection
StartTLS bool `json:"startTls"` // Start with plain connection then upgrade to TLS
InsecureSkipVerify bool `json:"insecureSkipVerify"` // Skip certificate verification
}
type Notification ¶
type Notification struct {
Name string `db:"name" json:"name"`
Type NotificationType `db:"type" json:"type"`
Config json.RawMessage `db:"config" json:"config"`
CreatedAt rfc3339time.Time `db:"created_at" json:"createdAt"`
UpdatedAt rfc3339time.Time `db:"updated_at" json:"updatedAt"`
}
func GetTemplate ¶
func GetTemplate(notifType NotificationType, name string) (*Notification, error)
GetTemplate returns a pre-filled template for the given notification type The name parameter can include special prefixes like "slack-" to get specialized templates
type NotificationLog ¶
type NotificationLog struct {
ID int `db:"id" json:"id"`
NotificationName string `db:"notification_name" json:"notificationName"`
Status string `db:"status" json:"status"`
Message *string `db:"message" json:"message,omitempty"`
Error *string `db:"error" json:"error,omitempty"`
CreatedAt rfc3339time.Time `db:"created_at" json:"createdAt"`
}
type NotificationStore ¶
type NotificationStore struct {
// contains filtered or unexported fields
}
func NewNotificationStore ¶
func NewNotificationStore(db *sqlx.DB) *NotificationStore
func (*NotificationStore) Create ¶
func (s *NotificationStore) Create(name string, notifType NotificationType, config json.RawMessage) (*Notification, error)
func (*NotificationStore) Delete ¶
func (s *NotificationStore) Delete(name string) error
func (*NotificationStore) Get ¶
func (s *NotificationStore) Get(name string) (*Notification, error)
func (*NotificationStore) GetLogs ¶
func (s *NotificationStore) GetLogs(limit int) ([]NotificationLog, error)
func (*NotificationStore) List ¶
func (s *NotificationStore) List() ([]Notification, error)
func (*NotificationStore) LogNotification ¶
func (s *NotificationStore) LogNotification(notificationName, status string, message, errorMsg *string) error
func (*NotificationStore) Update ¶
func (s *NotificationStore) Update(name string, notifType NotificationType, config json.RawMessage) (*Notification, error)
type NotificationType ¶
type NotificationType string
const ( TypeEmail NotificationType = "email" TypeSlack NotificationType = "slack" TypeTelegram NotificationType = "telegram" TypeWebhook NotificationType = "webhook" )
type SlackConfig ¶
type SlackConfig struct {
SlackWebhookURL string `json:"slackWebhookUrl" validate:"required,url"`
}
type TelegramConfig ¶
type WebhookConfig ¶
type WebhookConfig struct {
URL string `json:"url" validate:"required,url"`
Headers map[string]string `json:"headers,omitempty"`
RequestBodyType string `json:"requestBodyType,omitempty" validate:"omitempty,oneof=plain post json"` // plain, post (form-encoded), json
RequestBodyMessageKey string `json:"requestBodyMessageKey,omitempty"` // key for message in POST/JSON body (default: "text")
}
Click to show internal directories.
Click to hide internal directories.