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
- type AgentCond
- type Notice
- type NoticeEmailMedia
- type NoticeLevel
- type NoticeLevelConfig
- type NoticeMediaConfig
- type NoticeMediaInterface
- type NoticeMediaType
- type NoticeReceiver
- type NoticeScriptMedia
- type NoticeSetting
- func (this *NoticeSetting) AddMedia(mediaConfig *NoticeMediaConfig)
- 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 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" )
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"` }
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"` IsRead bool `bson:"isRead" json:"isRead"` // 已读 IsNotified bool `bson:"isNotified" json:"isNotified"` // 是否发送通知 Receivers []string `bson:"receivers" json:"receivers"` // 接收人ID列表 }
通知
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)
}
媒介接口
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.EnvVariable `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) 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"` }
通知设置
func (*NoticeSetting) AddMedia ¶
func (this *NoticeSetting) AddMedia(mediaConfig *NoticeMediaConfig)
添加媒介配置
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 NoticeWebhookMedia ¶
type NoticeWebhookMedia struct { URL string `yaml:"url" json:"url"` // URL中可以使用${NoticeSubject}, ${NoticeBody}两个变量 Method string `yaml:"method" json:"method"` }
Webhook媒介
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.