Documentation
¶
Overview ¶
Package notify 提供同步结果的多通道通知与存活心跳。
通道模型(借鉴 gickup):
- ntfy/gotify:推送「运行完成」事件(成功/失败皆可配)
- heartbeat: 周期 GET 成功/失败 URL,对接 healthchecks.io 一类监视
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Ntfy []NtfyConfig `yaml:"ntfy"`
Gotify []GotifyConfig `yaml:"gotify"`
Heartbeat *HeartbeatConfig `yaml:"heartbeat"`
// Webhook 通用 HTTP 回调
Webhook *WebhookConfig `yaml:"webhook"`
// OnlyFail true 时仅通知失败运行,降低噪声
OnlyFail bool `yaml:"only_fail"`
}
Config 通知总配置(壳层 overlay,不进 core)。
type GotifyConfig ¶
type GotifyConfig struct {
URL string `yaml:"url"`
Token string `yaml:"token"`
Events []string `yaml:"events"`
}
GotifyConfig Gotify 推送配置。
type Heartbeat ¶
type Heartbeat struct {
// contains filtered or unexported fields
}
Heartbeat 按「最近是否有失败」分路打点。 healthchecks.io 语义:成功 ping 保持绿,失败 ping 标红。
func (*Heartbeat) MarkResult ¶
MarkResult 记录一次运行结果,并立即向对应分路打点。
type HeartbeatConfig ¶
type HeartbeatConfig struct {
SuccessURLs []string `yaml:"success_urls"`
FailURLs []string `yaml:"fail_urls"`
// IntervalSeconds 周期;<=0 表示只随运行事件打点
IntervalSeconds int `yaml:"interval_seconds"`
}
HeartbeatConfig 成功/失败分路心跳(healthchecks.io / deadmanssnitch)。
type NtfyConfig ¶
type NtfyConfig struct {
URL string `yaml:"url"`
Token string `yaml:"token"`
User string `yaml:"user"`
Pass string `yaml:"password"`
Topic string `yaml:"topic"`
Events []string `yaml:"events"` // 空=success+failed;可选 success/failed
}
NtfyConfig ntfy.sh 推送配置。
type RunEvent ¶
type RunEvent struct {
TaskKey string
TaskName string
RunID uint
Status string // success | failed
Trigger string
Error string
ErrorType string
Duration time.Duration
EndAt time.Time
}
RunEvent 一次同步运行的结束事件。
type WebhookConfig ¶
type WebhookConfig struct {
// SuccessURL 成功回调(POST JSON)
SuccessURL string `yaml:"success_url"`
// FailURL 失败回调
FailURL string `yaml:"fail_url"`
SharedSecret string `yaml:"shared_secret"`
}
WebhookConfig 通用 HTTP 回调(成功/失败分路,兼容任意 IM/自建系统)。
Click to show internal directories.
Click to hide internal directories.