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 Notice
- type NoticeAliyunSmsMedia
- type NoticeDingTalkMedia
- type NoticeEmailMedia
- type NoticeLevel
- type NoticeLevelConfig
- type NoticeMediaConfig
- type NoticeMediaInterface
- type NoticeMediaType
- type NoticeQyWeixinMedia
- 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, message string, ...) (receiverIds []string)
- func (this *NoticeSetting) NotifyReceivers(level NoticeLevel, receivers []*NoticeReceiver, message string, ...) (receiverIds []string)
- func (this *NoticeSetting) RemoveMedia(mediaId string)
- func (this *NoticeSetting) Save() error
- type NoticeTeaSmsMedia
- type NoticeWebhookMedia
- type ProxyCond
Constants ¶
View Source
const ( NoticeLevelNone = uint8(0) NoticeLevelInfo = uint8(1) NoticeLevelWarning = uint8(2) NoticeLevelError = uint8(3) NoticeLevelSuccess = uint8(4) )
通知级别常量
View Source
const ( NoticeMediaTypeEmail = "email" NoticeMediaTypeWebhook = "webhook" NoticeMediaTypeScript = "script" NoticeMediaTypeDingTalk = "dingTalk" NoticeMediaTypeQyWeixin = "qyWeixin" NoticeMediaTypeAliyunSms = "aliyunSms" 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 Notice ¶
type Notice struct {
Id primitive.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 ¶ added in v0.1.2
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 NewNoticeAliyunSmsMedia ¶ added in v0.1.2
func NewNoticeAliyunSmsMedia() *NoticeAliyunSmsMedia
获取新对象
func (*NoticeAliyunSmsMedia) RequireUser ¶ added in v0.1.2
func (this *NoticeAliyunSmsMedia) RequireUser() bool
是否需要用户标识
func (*NoticeAliyunSmsMedia) Send ¶ added in v0.1.2
func (this *NoticeAliyunSmsMedia) Send(user string, subject string, body string) (resp []byte, err error)
type NoticeDingTalkMedia ¶ added in v0.1.2
type NoticeDingTalkMedia struct {
WebhookURL string `yaml:"webhookURL" json:"webhookURL"`
}
钉钉群机器人媒介
func NewNoticeDingTalkMedia ¶ added in v0.1.2
func NewNoticeDingTalkMedia() *NoticeDingTalkMedia
获取新对象
func (*NoticeDingTalkMedia) RequireUser ¶ added in v0.1.2
func (this *NoticeDingTalkMedia) RequireUser() bool
是否需要用户标识
func (*NoticeDingTalkMedia) Send ¶ added in v0.1.2
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"`
}
邮件媒介
func (*NoticeEmailMedia) RequireUser ¶ added in v0.1.2
func (this *NoticeEmailMedia) RequireUser() bool
是否需要用户标识
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 ¶ added in v0.1.2
type NoticeQyWeixinMedia struct {
CorporateId string `yaml:"corporateId" json:"corporateId"`
AgentId string `yaml:"agentId" json:"agentId"`
AppSecret string `yaml:"appSecret" json:"appSecret"`
}
企业微信媒介
func NewNoticeQyWeixinMedia ¶ added in v0.1.2
func NewNoticeQyWeixinMedia() *NoticeQyWeixinMedia
获取新对象
func (*NoticeQyWeixinMedia) RequireUser ¶ added in v0.1.2
func (this *NoticeQyWeixinMedia) RequireUser() bool
是否需要用户标识
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
格式化脚本
func (*NoticeScriptMedia) Generate ¶
func (this *NoticeScriptMedia) Generate(id string) (path string, err error)
保存到本地
func (*NoticeScriptMedia) RequireUser ¶ added in v0.1.2
func (this *NoticeScriptMedia) RequireUser() bool
是否需要用户标识
func (*NoticeScriptMedia) Send ¶
func (this *NoticeScriptMedia) Send(user string, subject string, body string) (resp []byte, err error)
发送
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 ¶ added in v0.1.2
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, message string, counter func(receiverId string, minutes int) int) (receiverIds []string)
发送通知
func (*NoticeSetting) NotifyReceivers ¶
func (this *NoticeSetting) NotifyReceivers(level NoticeLevel, receivers []*NoticeReceiver, message string, counter func(receiverId string, minutes int) int) (receiverIds []string)
发送通知给一组接收者
type NoticeTeaSmsMedia ¶ added in v0.1.2
type NoticeTeaSmsMedia struct {
Sign string `yaml:"sign" json:"sign"` // 签名名称
AccessId string `yaml:"accessId" json:"accessId"` // AccessId
AccessSecret string `yaml:"accessSecret" json:"accessSecret"` // AccessSecret
}
TeaOS云短信
func (*NoticeTeaSmsMedia) RequireUser ¶ added in v0.1.2
func (this *NoticeTeaSmsMedia) 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.Pair `yaml:"headers" json:"headers"`
Params []*shared.Pair `yaml:"params" json:"params"`
Body string `yaml:"body" json:"body"`
}
Webhook媒介
func (*NoticeWebhookMedia) AddHeader ¶ added in v0.1.2
func (this *NoticeWebhookMedia) AddHeader(name string, value string)
添加Header
func (*NoticeWebhookMedia) AddParam ¶ added in v0.1.2
func (this *NoticeWebhookMedia) AddParam(name string, value string)
添加参数
func (*NoticeWebhookMedia) RequireUser ¶ added in v0.1.2
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"`
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条件
Click to show internal directories.
Click to hide internal directories.