Documentation ¶
Index ¶
- Constants
- Variables
- func ConventTaskIdList(tasks []*Task) []string
- func GetTaskTableName(taskType string) string
- func InitDB() error
- func IsDupErr(err error) bool
- func IsValidStatus(status TaskEnum) bool
- type Task
- func (p *Task) BatchSetOwnerStatusWithPendingOutModify(db *gorm.DB, taskIdList []string, owner string, status TaskEnum) (int64, error)
- func (p *Task) BatchSetStatus(db *gorm.DB, taskIdList []string, status TaskEnum) error
- func (p *Task) BeforeCreate(scope *gorm.Scope) error
- func (p *Task) Create(db *gorm.DB, taskType, pos string, task *Task) error
- func (p *Task) CreateNextTable(db *gorm.DB, taskType, pos string) error
- func (p *Task) Find(db *gorm.DB, taskId string) (*Task, error)
- func (p *Task) GenTaskId(taskType, pos string) string
- func (p *Task) GetAliveTaskCount(db *gorm.DB, taskType, pos string) (int, error)
- func (p *Task) GetAliveTaskList(db *gorm.DB, taskType, pos string, limit int) ([]*Task, error)
- func (p *Task) GetAllTaskCount(db *gorm.DB, taskType, pos string) (int, error)
- func (p *Task) GetAssignTasksByOwnerStatus(db *gorm.DB, taskIdList []string, owner string, status TaskEnum, limit int64) ([]*Task, error)
- func (p *Task) GetLongTimeProcessing(db *gorm.DB, taskType, pos string, maxProcessTime int64, limit int) ([]*Task, error)
- func (p *Task) GetTaskCountByStatus(db *gorm.DB, taskType, pos string, status int) (int, error)
- func (p *Task) GetTaskList(db *gorm.DB, pos string, taskType string, status TaskEnum, limit int) ([]*Task, error)
- func (p *Task) IncreaseCrtRetryNum(db *gorm.DB, taskId string) error
- func (p *Task) ModifyTimeoutPending(db *gorm.DB, taskType, pos string, maxProcessTime int64) error
- func (p *Task) Save(db *gorm.DB, task *Task) error
- func (p *Task) SetContext(db *gorm.DB, taskId, context string) error
- func (p *Task) SetScheduleLog(db *gorm.DB, ScheduleLog string) error
- func (p *Task) SetStatus(db *gorm.DB, taskId string, status TaskEnum) error
- func (p *Task) SetStatusFailed(db *gorm.DB, taskId string) error
- func (p *Task) SetStatusPending(db *gorm.DB, taskId string) error
- func (p *Task) SetStatusSucc(db *gorm.DB, taskId string) error
- func (p *Task) SetStatusWithOutModifyTime(db *gorm.DB, taskId string, status TaskEnum) error
- func (p *Task) TableName() string
- func (p *Task) UpdateTask(db *gorm.DB) error
- type TaskEnum
- type TaskPos
- func (this *TaskPos) BeforeCreate(scope *gorm.Scope) error
- func (p *TaskPos) Create(db *gorm.DB, task *TaskPos) error
- func (p *TaskPos) GetBeginSchedulePos(db *gorm.DB, taskSetName string) (int, error)
- func (p *TaskPos) GetNextPos(pos string) string
- func (p *TaskPos) GetRandomSchedulePos(db *gorm.DB, taskSetName string) (int, error)
- func (p *TaskPos) GetTaskPos(db *gorm.DB, taskSetName string) (*TaskPos, error)
- func (p *TaskPos) GetTaskPosList(db *gorm.DB) ([]*TaskPos, error)
- func (p *TaskPos) Save(db *gorm.DB, task *TaskPos) error
- func (p *TaskPos) TableName() string
- type TaskScheduleCfg
- func (p *TaskScheduleCfg) Create(db *gorm.DB, task *TaskScheduleCfg) error
- func (p *TaskScheduleCfg) GetTaskTypeCfg(db *gorm.DB, taskType string) (*TaskScheduleCfg, error)
- func (p *TaskScheduleCfg) GetTaskTypeCfgList(db *gorm.DB) ([]*TaskScheduleCfg, error)
- func (p *TaskScheduleCfg) Save(db *gorm.DB, task *TaskScheduleCfg) error
- func (p *TaskScheduleCfg) TableName() string
Constants ¶
const (
BEGIN_TABLE_POS = 1
)
const (
GORM_DUPLICATE_ERR_KEY = "Duplicate entry"
)
const (
// 优先1年
MAX_PRIORITY = 3600 * 24 * 30 * 12
)
Variables ¶
var DB *gorm.DB
Functions ¶
func ConventTaskIdList ¶
ConventTaskIdList 任务信息列表转换成对应任务ID列表
func GetTaskTableName ¶
GetTaskTableName 获取short task 表名
Types ¶
type Task ¶
type Task struct { Id uint64 UserId string TaskId string TaskType string TaskStage string Status int Priority int CrtRetryNum int MaxRetryNum int MaxRetryInterval int ScheduleLog string TaskContext string // task struct json string OrderTime int64 CreateTime *time.Time ModifyTime *time.Time }
Task 任务表
var TaskNsp Task
func (*Task) BatchSetOwnerStatusWithPendingOutModify ¶
func (*Task) BatchSetStatus ¶
BatchSetStatus batch set
func (*Task) BeforeCreate ¶
BeforeCreate 创建之前的回调函数
func (*Task) CreateNextTable ¶
CreateNextTable 创建新表
func (*Task) GetAliveTaskCount ¶
GetAliveTaskCount 获取处于激活状态的任务数
func (*Task) GetAliveTaskList ¶
GetAliveTaskList 获取处于激活状态的任务列表
func (*Task) GetAllTaskCount ¶
GetAllTaskCount 获取所有任务数
func (*Task) GetAssignTasksByOwnerStatus ¶
func (p *Task) GetAssignTasksByOwnerStatus(db *gorm.DB, taskIdList []string, owner string, status TaskEnum, limit int64) ([]*Task, error)
GetAssignTasksByOwnerStatus 在指定任务列表中获取对应归宿和状态的任务列表
func (*Task) GetLongTimeProcessing ¶
func (p *Task) GetLongTimeProcessing(db *gorm.DB, taskType, pos string, maxProcessTime int64, limit int) ([]*Task, error)
GetLongTimeProcessing 获取超过最大执行时间的任务列表
func (*Task) GetTaskCountByStatus ¶
GetTaskCountByStatus 根据状态获取任务数
func (*Task) GetTaskList ¶
func (p *Task) GetTaskList(db *gorm.DB, pos string, taskType string, status TaskEnum, limit int) ([]*Task, error)
GetTaskList 获取记录列表
func (*Task) IncreaseCrtRetryNum ¶
IncreaseCrtRetryNum 增加一次对应任务的重试次数
func (*Task) ModifyTimeoutPending ¶
ModifyTimeoutPending 更新超过最大执行时间的任务为等待状态
func (*Task) SetContext ¶
SetContext 设置任务的上下文
func (*Task) SetScheduleLog ¶
SetScheduleLog 设置任务的调度信息
func (*Task) SetStatusFailed ¶
SetStatusFailed 设置任务为失败状态
func (*Task) SetStatusPending ¶
SetStatusPending 设置任务为等待状态
func (*Task) SetStatusSucc ¶
SetStatusSucc 设置任务为成功状态
func (*Task) SetStatusWithOutModifyTime ¶
SetStatusWithOutModifyTime 设置对应任务状态,不更新modify_time
type TaskPos ¶
type TaskPos struct { Id uint64 TaskType string ScheduleBeginPos int ScheduleEndPos int CreateTime *time.Time ModifyTime *time.Time }
TaskPos taskpos
var TaskPosNsp TaskPos
func (*TaskPos) BeforeCreate ¶
BeforeCreate 创建之前的回调函数
func (*TaskPos) GetBeginSchedulePos ¶
GetBeginSchedulePos 获取开始调度指针
func (*TaskPos) GetRandomSchedulePos ¶
GetRandomSchedulePos 生成随机调度指针
func (*TaskPos) GetTaskPos ¶
GetTaskPos 获取记录
func (*TaskPos) GetTaskPosList ¶
GetTaskPosList 获取记录列表
type TaskScheduleCfg ¶
type TaskScheduleCfg struct { TaskType string ScheduleLimit int ScheduleInterval int MaxProcessingTime int64 MaxRetryNum int MaxRetryInterval int CreateTime *time.Time ModifyTime *time.Time }
TaskScheduleCfg cfg
var TaskTypeCfgNsp TaskScheduleCfg
func (*TaskScheduleCfg) Create ¶
func (p *TaskScheduleCfg) Create(db *gorm.DB, task *TaskScheduleCfg) error
Create 创建记录
func (*TaskScheduleCfg) GetTaskTypeCfg ¶
func (p *TaskScheduleCfg) GetTaskTypeCfg(db *gorm.DB, taskType string) (*TaskScheduleCfg, error)
GetTaskTypeCfg 获取记录
func (*TaskScheduleCfg) GetTaskTypeCfgList ¶
func (p *TaskScheduleCfg) GetTaskTypeCfgList(db *gorm.DB) ([]*TaskScheduleCfg, error)
GetTaskTypeCfgList 获取记录列表
func (*TaskScheduleCfg) Save ¶
func (p *TaskScheduleCfg) Save(db *gorm.DB, task *TaskScheduleCfg) error
Save 保存记录