Documentation ¶
Index ¶
- Constants
- func AllNoticeLevels() []maps.Map
- func AllNoticeMediaTypes() []maps.Map
- func FindNoticeLevel(level NoticeLevel) maps.Map
- func FindNoticeLevelName(level NoticeLevel) string
- func FindNoticeMediaType(mediaType string) maps.Map
- func FindNoticeMediaTypeName(mediaType string) string
- func IsFailureLevel(level NoticeLevel) bool
- type AgentCond
- type Item
- type Notice
- type NoticeAliyunSmsMedia
- type NoticeDingTalkMedia
- type NoticeEmailMedia
- type NoticeLevel
- type NoticeLevelConfig
- type NoticeMediaConfig
- type NoticeMediaInterface
- type NoticeMediaType
- type NoticeQyWeixinMedia
- type NoticeQyWeixinRobotMedia
- type NoticeReceiver
- type NoticeScriptMedia
- func (this *NoticeScriptMedia) AddEnv(name, value string)
- func (this *NoticeScriptMedia) FormattedScript() string
- func (this *NoticeScriptMedia) Generate(id string) (path string, err error)
- func (this *NoticeScriptMedia) RequireUser() bool
- func (this *NoticeScriptMedia) Send(user string, subject string, body string) (resp []byte, err error)
- type NoticeSetting
- func (this *NoticeSetting) AddMedia(mediaConfig *NoticeMediaConfig)
- func (this *NoticeSetting) FindAllNoticeReceivers(level ...NoticeLevel) []*NoticeReceiver
- func (this *NoticeSetting) FindMedia(mediaId string) *NoticeMediaConfig
- func (this *NoticeSetting) FindReceiver(receiverId string) (level NoticeLevel, receiver *NoticeReceiver)
- func (this *NoticeSetting) LevelConfig(level NoticeLevel) *NoticeLevelConfig
- func (this *NoticeSetting) Notify(level NoticeLevel, subject string, message string, ...) (receiverIds []string)
- func (this *NoticeSetting) NotifyReceivers(level NoticeLevel, receivers []*NoticeReceiver, subject string, message string, ...) (receiverIds []string)
- func (this *NoticeSetting) RemoveMedia(mediaId string)
- func (this *NoticeSetting) Save() error
- type NoticeTeaSmsMedia
- type NoticeTelegramMedia
- type NoticeWebhookMedia
- type ProxyCond
- type TextFormat
Constants ¶
View Source
const ( FormatText = "text" FormatMarkdown = "markdown" )
常用的内容文本格式
View Source
const ( NoticeLevelNone = NoticeLevel(0) NoticeLevelInfo = NoticeLevel(1) NoticeLevelWarning = NoticeLevel(2) NoticeLevelError = NoticeLevel(3) NoticeLevelSuccess = NoticeLevel(4) )
通知级别常量
View Source
const ( NoticeMediaTypeEmail = "email" NoticeMediaTypeWebhook = "webhook" NoticeMediaTypeScript = "script" NoticeMediaTypeDingTalk = "dingTalk" NoticeMediaTypeQyWeixin = "qyWeixin" NoticeMediaTypeQyWeixinRobot = "qyWeixinRobot" NoticeMediaTypeAliyunSms = "aliyunSms" NoticeMediaTypeTelegram = "telegram" NoticeMediaTypeTeaSms = "teaSms" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AgentCond ¶
type AgentCond struct { AgentId string `bson:"agentId" json:"agentId"` AppId string `bson:"appId" json:"appId"` TaskId string `bson:"taskId" json:"taskId"` ItemId string `bson:"itemId" json:"itemId"` Level uint8 `bson:"level" json:"level"` Threshold string `bson:"threshold" json:"threshold"` }
Agent条件
type Item ¶
type Item struct { On bool `yaml:"on" json:"on"` // 是否开启 Level NoticeLevel `yaml:"level" json:"level"` Receivers []*NoticeReceiver `yaml:"receivers" json:"receivers"` Subject string `yaml:"subject" json:"subject"` Body string `yaml:"body" json:"body"` }
通知条目配置,用于某个项目的细项通知配置
type Notice ¶
type Notice struct { Id shared.ObjectId `bson:"_id" json:"id"` // 数据库存储的ID Proxy ProxyCond `bson:"proxy" json:"proxy"` // 代理相关参数 Agent AgentCond `bson:"agent" json:"agent"` // 主机相关参数 Timestamp int64 `bson:"timestamp" json:"timestamp"` // 时间戳 Message string `bson:"message" json:"message"` // 消息内容 MessageHash string `bson:"messageHash" json:"messageHash"` // 消息内容Hash:crc32(message) IsRead bool `bson:"isRead" json:"isRead"` // 已读 IsNotified bool `bson:"isNotified" json:"isNotified"` // 是否发送通知 Receivers []string `bson:"receivers" json:"receivers"` // 接收人ID列表 }
通知
type NoticeAliyunSmsMedia ¶
type NoticeAliyunSmsMedia struct { Sign string `yaml:"sign" json:"sign"` // 签名名称 TemplateCode string `yaml:"templateCode" json:"templateCode"` // 模板CODE Variables []*shared.Variable `yaml:"variables" json:"variables"` // 变量 AccessKeyId string `yaml:"accessKeyId" json:"accessKeyId"` // AccessKeyId AccessKeySecret string `yaml:"accessKeySecret" json:"accessKeySecret"` // AccessKeySecret }
阿里云短信
func (*NoticeAliyunSmsMedia) RequireUser ¶
func (this *NoticeAliyunSmsMedia) RequireUser() bool
是否需要用户标识
func (*NoticeAliyunSmsMedia) Send ¶
func (this *NoticeAliyunSmsMedia) Send(user string, subject string, body string) (resp []byte, err error)
type NoticeDingTalkMedia ¶
type NoticeDingTalkMedia struct {
WebhookURL string `yaml:"webhookURL" json:"webhookURL"`
}
钉钉群机器人媒介
func (*NoticeDingTalkMedia) RequireUser ¶
func (this *NoticeDingTalkMedia) RequireUser() bool
是否需要用户标识
func (*NoticeDingTalkMedia) Send ¶
func (this *NoticeDingTalkMedia) Send(user string, subject string, body string) (resp []byte, err error)
type NoticeEmailMedia ¶
type NoticeEmailMedia struct { SMTP string `yaml:"smtp" json:"smtp"` Username string `yaml:"username" json:"username"` Password string `yaml:"password" json:"password"` From string `yaml:"from" json:"from"` }
邮件媒介
type NoticeLevelConfig ¶
type NoticeLevelConfig struct { ShouldNotify bool `yaml:"shouldNotify" json:"shouldNotify"` Receivers []*NoticeReceiver `yaml:"receivers" json:"receivers"` }
级别配置
func (*NoticeLevelConfig) AddReceiver ¶
func (this *NoticeLevelConfig) AddReceiver(receiver *NoticeReceiver)
添加接收人
func (*NoticeLevelConfig) FindReceiver ¶
func (this *NoticeLevelConfig) FindReceiver(receiverId string) *NoticeReceiver
查找单个接收人
func (*NoticeLevelConfig) RemoveMediaReceivers ¶
func (this *NoticeLevelConfig) RemoveMediaReceivers(mediaId string)
移除某个媒介的所有接收人
func (*NoticeLevelConfig) RemoveReceiver ¶
func (this *NoticeLevelConfig) RemoveReceiver(receiverId string)
移除接收人
type NoticeMediaConfig ¶
type NoticeMediaConfig struct { Id string `yaml:"id" json:"id"` On bool `yaml:"on" json:"on"` Name string `yaml:"name" json:"name"` Type NoticeMediaType `yaml:"type" json:"type"` Options map[string]interface{} `yaml:"options" json:"options"` TimeFrom string `yaml:"timeFrom" json:"timeFrom"` // 发送的开始时间 TimeTo string `yaml:"timeTo" json:"timeTo"` // 发送的结束时间 RateMinutes int `yaml:"rateMinutes" json:"rateMinutes"` // 速率限制之时间范围 RateCount int `yaml:"rateCount" json:"rateCount"` // 速率限制之数量 }
媒介配置定义
func (*NoticeMediaConfig) Raw ¶
func (this *NoticeMediaConfig) Raw() (NoticeMediaInterface, error)
取得原始的媒介
func (*NoticeMediaConfig) ShouldNotify ¶
func (this *NoticeMediaConfig) ShouldNotify(countSent int) bool
是否应该推送
type NoticeMediaInterface ¶
type NoticeMediaInterface interface { // 发送 Send(user string, subject string, body string) (resp []byte, err error) // 是否可以需要用户标识 RequireUser() bool }
媒介接口
type NoticeQyWeixinMedia ¶
type NoticeQyWeixinMedia struct { CorporateId string `yaml:"corporateId" json:"corporateId"` AgentId string `yaml:"agentId" json:"agentId"` AppSecret string `yaml:"appSecret" json:"appSecret"` TextFormat TextFormat `yaml:"textFormat" json:"textFormat"` }
企业微信媒介
func (*NoticeQyWeixinMedia) RequireUser ¶
func (this *NoticeQyWeixinMedia) RequireUser() bool
是否需要用户标识
type NoticeQyWeixinRobotMedia ¶
type NoticeQyWeixinRobotMedia struct { WebhookURL string `yaml:"webhookURL" json:"webhookURL"` TextFormat TextFormat `yaml:"textFormat" json:"textFormat"` }
企业微信群机器人媒介
func NewNoticeQyWeixinRobotMedia ¶
func NewNoticeQyWeixinRobotMedia() *NoticeQyWeixinRobotMedia
获取新对象
func (*NoticeQyWeixinRobotMedia) RequireUser ¶
func (this *NoticeQyWeixinRobotMedia) RequireUser() bool
是否需要用户标识
func (*NoticeQyWeixinRobotMedia) Send ¶
func (this *NoticeQyWeixinRobotMedia) Send(user string, subject string, body string) (resp []byte, err error)
type NoticeReceiver ¶
type NoticeReceiver struct { Id string `yaml:"id" json:"id"` On bool `yaml:"on" json:"on"` Name string `yaml:"name" json:"name"` MediaId string `yaml:"mediaId" json:"mediaId"` User string `yaml:"user" json:"user"` // 用户标识 }
接收者
type NoticeScriptMedia ¶
type NoticeScriptMedia struct { Path string `yaml:"path" json:"path"` ScriptType string `yaml:"scriptType" json:"scriptType"` // 脚本类型,可以为path, code ScriptLang string `yaml:"scriptLang" json:"scriptLang"` // 脚本语言 Script string `yaml:"script" json:"script"` // 脚本代码 Cwd string `yaml:"cwd" json:"cwd"` Env []*shared.Variable `yaml:"env" json:"env"` }
脚本媒介
func (*NoticeScriptMedia) FormattedScript ¶
func (this *NoticeScriptMedia) FormattedScript() string
格式化脚本
type NoticeSetting ¶
type NoticeSetting struct { Levels map[NoticeLevel]*NoticeLevelConfig `yaml:"levels" json:"levels"` Medias []*NoticeMediaConfig `yaml:"medias" json:"medias"` SoundOn bool `yaml:"soundOn" json:"soundOn"` // 提示声音 }
通知设置
func (*NoticeSetting) AddMedia ¶
func (this *NoticeSetting) AddMedia(mediaConfig *NoticeMediaConfig)
添加媒介配置
func (*NoticeSetting) FindAllNoticeReceivers ¶
func (this *NoticeSetting) FindAllNoticeReceivers(level ...NoticeLevel) []*NoticeReceiver
查找一个或多个级别对应的接收者,并合并相同的接收者
func (*NoticeSetting) FindMedia ¶
func (this *NoticeSetting) FindMedia(mediaId string) *NoticeMediaConfig
查找媒介
func (*NoticeSetting) FindReceiver ¶
func (this *NoticeSetting) FindReceiver(receiverId string) (level NoticeLevel, receiver *NoticeReceiver)
查找接收人
func (*NoticeSetting) LevelConfig ¶
func (this *NoticeSetting) LevelConfig(level NoticeLevel) *NoticeLevelConfig
查找级别配置
func (*NoticeSetting) Notify ¶
func (this *NoticeSetting) Notify(level NoticeLevel, subject string, message string, counter func(receiverId string, minutes int) int) (receiverIds []string)
发送通知
func (*NoticeSetting) NotifyReceivers ¶
func (this *NoticeSetting) NotifyReceivers(level NoticeLevel, receivers []*NoticeReceiver, subject string, message string, counter func(receiverId string, minutes int) int) (receiverIds []string)
发送通知给一组接收者
type NoticeTeaSmsMedia ¶
type NoticeTeaSmsMedia struct { Sign string `yaml:"sign" json:"sign"` // 签名名称 AccessId string `yaml:"accessId" json:"accessId"` // AccessId AccessSecret string `yaml:"accessSecret" json:"accessSecret"` // AccessSecret }
TeaOS云短信
type NoticeTelegramMedia ¶
type NoticeTelegramMedia struct {
Token string `yaml:"token" json:"token"`
}
Telegram媒介
func (*NoticeTelegramMedia) RequireUser ¶
func (this *NoticeTelegramMedia) RequireUser() bool
是否需要用户标识
type NoticeWebhookMedia ¶
type NoticeWebhookMedia struct { URL string `yaml:"url" json:"url"` // URL中可以使用${NoticeSubject}, ${NoticeBody}两个变量 Method string `yaml:"method" json:"method"` ContentType string `yaml:"contentType" json:"contentType"` // 内容类型:params|body Headers []*shared.Variable `yaml:"headers" json:"headers"` Params []*shared.Variable `yaml:"params" json:"params"` Body string `yaml:"body" json:"body"` }
Webhook媒介
func (*NoticeWebhookMedia) AddHeader ¶
func (this *NoticeWebhookMedia) AddHeader(name string, value string)
添加Header
func (*NoticeWebhookMedia) AddParam ¶
func (this *NoticeWebhookMedia) AddParam(name string, value string)
添加参数
func (*NoticeWebhookMedia) RequireUser ¶
func (this *NoticeWebhookMedia) RequireUser() bool
是否需要用户标识
func (*NoticeWebhookMedia) Send ¶
func (this *NoticeWebhookMedia) Send(user string, subject string, body string) (resp []byte, err error)
发送
type ProxyCond ¶
type ProxyCond struct { ServerId string `bson:"serverId" json:"serverId"` Websocket bool `bson:"websocket" json:"websocket"` LocationId string `bson:"locationId" json:"serverId"` RewriteId string `bson:"rewriteId" json:"serverId"` BackendId string `bson:"backendId" json:"serverId"` FastcgiId string `bson:"fastcgiId" json:"serverId"` Level uint8 `bson:"level" json:"level"` }
Proxy条件
Source Files ¶
Click to show internal directories.
Click to hide internal directories.