cronjob

package
v0.0.0-...-f14b9eb Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTask

func AddTask(t TaskConfig) error

func Init

func Init(db *gorm.DB, serviceName string, taskList []TaskConfig)

func InitAndRun

func InitAndRun(db *gorm.DB, serviceName string, taskList []TaskConfig)

func RemoveTask

func RemoveTask(t TaskConfig)

func UpdateTask

func UpdateTask(db *gorm.DB, t TaskConfig) error

Types

type Task

type Task struct {
	sync.Mutex
	sync.Once
	// contains filtered or unexported fields
}

type TaskConfig

type TaskConfig struct {
	Code   string                       `gorm:"primarykey;" json:"code"` //英文编码
	Cmd    int                          `gorm:"type:int;" json:"cmd"`    //数字编码
	Name   string                       `gorm:"type:varchar(100)" json:"name"`
	Value  string                       `gorm:"type:varchar(100)" json:"value"`         //执行周期
	Remark string                       `gorm:"type:varchar(200)" json:"remark"`        //备注
	State  int                          `gorm:"type:tinyint(4);default:1" json:"state"` //0-禁用、1-启用
	Param  string                       `gorm:"type:text" json:"param"`                 //参数,Json
	Do     func() (cron.EntryID, error) `gorm:"-" json:"-"`                             //执行逻辑
}

func FindTaskConfigByCode

func FindTaskConfigByCode(db *gorm.DB, code string) TaskConfig

type TaskEvent

type TaskEvent struct {
	Cmd   int    `json:"cmd"`
	Code  string `json:"code"`
	Value string `json:"value"` //当operation=4时,必须有值

	Remark string `json:"remark"`
	// contains filtered or unexported fields
}

type TaskEventType

type TaskEventType int
const (
	EnableType  TaskEventType //启用
	DisableType               //禁用
	RunOnceType               //执行一次
	UpdateType                //修改任务
)

Jump to

Keyboard shortcuts

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