cron_task

package
v0.0.0-...-e5d1c0a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

README

fangfang-api.cron_task

后台任务表

序号 名称 描述 类型 为空 额外 默认值
1 id 主键 int unsigned PRI NO auto_increment
2 name 任务名称 varchar(64) MUL NO
3 spec crontab 表达式 varchar(64) NO
4 command 执行命令 varchar(255) NO
5 protocol 执行方式 1:shell 2:http tinyint unsigned NO 1
6 http_method http 请求方式 1:get 2:post tinyint unsigned NO 1
7 timeout 超时时间(单位:秒) int unsigned NO 60
8 retry_times 重试次数 tinyint(1) NO 3
9 retry_interval 重试间隔(单位:秒) int NO 60
10 notify_status 执行结束是否通知 1:不通知 2:失败通知 3:结束通知 4:结果关键字匹配通知 tinyint unsigned NO 0
11 notify_type 通知类型 1:邮件 2:webhook tinyint unsigned NO 1
12 notify_receiver_email 通知者邮箱地址(多个用,分割) varchar(255) NO
13 notify_keyword 通知匹配关键字(多个用,分割) varchar(255) NO
14 remark 备注 varchar(100) NO
15 is_used 是否启用 1:是 -1:否 tinyint(1) NO 1
16 created_at 创建时间 timestamp NO DEFAULT_GENERATED CURRENT_TIMESTAMP
17 created_user 创建人 varchar(60) NO
18 updated_at 更新时间 timestamp NO DEFAULT_GENERATED on update CURRENT_TIMESTAMP CURRENT_TIMESTAMP
19 updated_user 更新人 varchar(60) NO

Documentation

Index

Constants

View Source
const (
	ProtocolShell = 1
	ProtocolHTTP  = 2

	HttpMethodGet  = 1
	HttpMethodPost = 2

	NotifyStatusNo      = 1
	NotifyStatusFailed  = 2
	NotifyStatusStopped = 3
	NotifyStatusKeyword = 4

	NotifyTypeEmail   = 1
	NotifyTypeWebhook = 2

	IsUsedYES = 1
	IsUsedNo  = -1
)

Variables

View Source
var HttpMethodText = map[int]string{
	HttpMethodGet:  "GET",
	HttpMethodPost: "POST",
}
View Source
var IsUsedText = map[int]string{
	IsUsedYES: "启用",
	IsUsedNo:  "禁用",
}
View Source
var NotifyStatusText = map[int]string{
	NotifyStatusNo:      "不通知",
	NotifyStatusFailed:  "失败通知",
	NotifyStatusStopped: "结束通知",
	NotifyStatusKeyword: "结果关键字匹配通知",
}
View Source
var NotifyTypeText = map[int]string{
	NotifyTypeEmail:   "邮件",
	NotifyTypeWebhook: "Webhook",
}
View Source
var ProtocolText = map[int]string{
	ProtocolShell: "SHELL",
	ProtocolHTTP:  "HTTP",
}

Functions

func NewQueryBuilder

func NewQueryBuilder() *cronTaskQueryBuilder

Types

type CronTask

type CronTask struct {
	Id                  int32     // 主键
	Name                string    // 任务名称
	Spec                string    // crontab 表达式
	Command             string    // 执行命令
	Protocol            int32     // 执行方式 1:shell 2:http
	HttpMethod          int32     // http 请求方式 1:get 2:post
	Timeout             int32     // 超时时间(单位:秒)
	RetryTimes          int32     // 重试次数
	RetryInterval       int32     // 重试间隔(单位:秒)
	NotifyStatus        int32     // 执行结束是否通知 1:不通知 2:失败通知 3:结束通知 4:结果关键字匹配通知
	NotifyType          int32     // 通知类型 1:邮件 2:webhook
	NotifyReceiverEmail string    // 通知者邮箱地址(多个用,分割)
	NotifyKeyword       string    // 通知匹配关键字(多个用,分割)
	Remark              string    // 备注
	IsUsed              int32     // 是否启用 1:是  -1:否
	CreatedAt           time.Time `gorm:"time"` // 创建时间
	CreatedUser         string    // 创建人
	UpdatedAt           time.Time `gorm:"time"` // 更新时间
	UpdatedUser         string    // 更新人
}

CronTask 后台任务表

func NewModel

func NewModel() *CronTask

func (*CronTask) Create

func (t *CronTask) Create(db *gorm.DB) (id int32, err error)

func (*CronTask) TableName

func (*CronTask) TableName() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL