Documentation
¶
Overview ¶
Package cron 实现计划任务模块:按 cron 表达式定时执行命令或 HTTP 请求,并保留最近的执行记录。
Index ¶
Constants ¶
View Source
const ( TypeCommand = "command" TypeHTTP = "http" )
任务类型
View Source
const ID = "cron"
ID 是模块标识。
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Run ¶
type Run struct {
Start time.Time `json:"start"`
Duration int64 `json:"durationMs"`
OK bool `json:"ok"`
Output string `json:"output"`
Manual bool `json:"manual"`
// Attempts 为本次执行实际尝试的次数(含重试),无重试时为 1
Attempts int `json:"attempts"`
}
Run 是一次执行记录。
type Task ¶
type Task struct {
Key string `json:"key"`
Name string `json:"name"`
// Group 为列表中的分组名称,只影响管理界面的展示,留空为未分组
Group string `json:"group"`
Enable bool `json:"enable"`
// Spec 为 cron 表达式,例如 "0 3 * * *"、"*/30 * * * * *"、"@every 10m"
Spec string `json:"spec"`
Type string `json:"type"`
Command string `json:"command"`
HTTP webhook.Config `json:"http"`
Remark string `json:"remark"`
// Retries 为失败后的自动重试次数(0 不重试),RetryInterval 为两次尝试之间的间隔秒数
Retries int `json:"retries"`
RetryInterval int `json:"retryInterval"`
// MuteFail 为 true 时该任务最终失败也不发布 cron.failed 事件;默认 false,已有任务保持通知
MuteFail bool `json:"muteFail"`
}
Task 是一个计划任务。
Click to show internal directories.
Click to hide internal directories.