task_manager

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package task_manager

Index

Constants

View Source
const (
	ErrTaskStart         = "task start failed"
	ErrTaskAlreadyAttach = "task already attached"
	ErrTaskTimeout       = "task run timeout"
)
View Source
const (
	Created status = iota
	Started
	Stopped
	Running
	Done
	Exited // goroutine被回收强制停止
	Unknown
)
View Source
const EmptyName = ""
View Source
const (
	TaskManagerPrefix = "[Task Manager]"
)

Variables

View Source
var TaskGroup []interface{}
View Source
var TaskManager *taskManager
View Source
var TickerMap = map[string]*OneTicker{}

Functions

func AddCronTask added in v1.1.1

func AddCronTask(id, name, spec string)

func GetAllCronTasks added in v1.1.1

func GetAllCronTasks() []taskRes

GetAllCronTasks 定时任务

func GetSetOfTasks added in v1.1.1

func GetSetOfTasks()

GetSetOfTasks 任务去重处理,理论上不存在重复的uuid 仅针对Task

func InitTaskManager added in v1.1.1

func InitTaskManager()

func ListAllTasks

func ListAllTasks() ([]string, error)

ListAllTasks 列出全部任务

func NewTask

func NewTask(name string, timeout int) *task

Types

type OneTicker added in v1.1.1

type OneTicker struct {
	Ch         chan bool `json:",omitempty"`
	UUID       string    `json:"uuid"`
	Name       string    `json:"name"`
	Des        string    `json:"des"`
	Stopped    bool      `json:"stopped"`
	CreateTime int64     `json:"create_time"`
	Duration   int       `json:"duration"`
	LastRun    int64     `json:"lastRun"`
}

func (*OneTicker) Start added in v1.1.1

func (tc *OneTicker) Start() (uuid string, err error)

func (*OneTicker) Stop added in v1.1.1

func (tc *OneTicker) Stop() (uuid string, err error)

type OneTickerRes added in v1.1.1

type OneTickerRes struct {
	UUID       string `json:"uuid"`
	Name       string `json:"name"`
	Des        string `json:"des"`
	Stopped    bool   `json:"stopped"`
	CreateTime int64  `json:"create_time"`
	Duration   int    `json:"duration"`
	LastRun    int64  `json:"lastRun"`
}

func GetAllBackgroundTasks

func GetAllBackgroundTasks() []OneTickerRes

Jump to

Keyboard shortcuts

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