task

package
v1.6.7 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitManagement

func InitManagement()

初始化并启动任务管理

Types

type Item

type Item struct {
	RuleList     []*Rule               //规则列表
	ExecFunc     func(item *Item) bool //任务执行方法
	CallbackFunc func(item *Item)      //任务回调方法
	LastExecDate time.Time             //最后执行任务的时间
	Args         []interface{}         //任务数据
	Lock         sync.RWMutex
}

Item 任务项

type Management

type Management struct {
	// contains filtered or unexported fields
}

Management 任务管理

var ManagementService *Management

全局类

func NewManagement

func NewManagement() *Management

NewManagement 创建管理任务工厂方法

func (*Management) Add

func (m *Management) Add(item *Item)

Add 添加一个任务项

func (*Management) AddTask

func (m *Management) AddTask(
	second string,
	minute string,
	hour string,
	dayOfMonth string,
	month string,
	dayOfWeek string,
	exec func(item *Item) bool,
	callback func(item *Item),
	args ...interface{}) *Item

AddTask 使用选项添加一个任务项

func (*Management) AddTaskString

func (m *Management) AddTaskString(taskStr string, exec func(item *Item) bool, callback func(item *Item), args ...interface{}) *Item

AddTaskString 使用选项字符串添加一个任务项

func (*Management) ClearTask

func (m *Management) ClearTask()

ClearTask 清空任务列表

func (*Management) RemoveForeach

func (m *Management) RemoveForeach(f func(*Item) bool)

RemoveForeach foreach 回调方法删除一个任务

func (*Management) RemoveTask

func (m *Management) RemoveTask(item *Item)

RemoveTask 删除列表中一个任务

func (*Management) Start

func (m *Management) Start()

Start 开始

func (*Management) Status

func (m *Management) Status() string

func (*Management) Stop

func (m *Management) Stop()

type Rule

type Rule struct {
	Raw    string   //原始值
	Type   TimeType //时间类型
	IsLoop bool     //是否循环
	Value  int      //循环值
}

Rule 任务规则

type TimeType

type TimeType int

TimeType 时间类型

const (
	Second TimeType = iota
	Minute
	Hour
	DayOfMonth
	Month
	DayOfWeek
)

Jump to

Keyboard shortcuts

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