tasksdk

package
v0.0.0-...-f6ff08b Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package Task inft && schedule

Index

Constants

View Source
const (
	DEFAULT_TIME_INTERVAL = 20 // for second
)
View Source
const (
	MAX_ERR_MSG_LEN = 256
)

Variables

View Source
var MaxConcurrentRunTimes = 20

Functions

func CycleReloadCfg

func CycleReloadCfg()

CycleReloadCfg func cycle reload cfg 在固定时间间隔后刷新配置

func InitSvr

func InitSvr(taskServerHost, lockServerHost string)

InitSvr task svr host

func LoadCfg

func LoadCfg() error

LoadCfg func load cfg

func RandNum

func RandNum(num int64) int64

RandNum func for rand num

func RegisterHandler

func RegisterHandler(handler *TaskHandler)

RegisterHandler func RegisterHandler

Types

type ScheduleData

type ScheduleData struct {
	TraceId string
	ErrMsg  string
	Cost    string
}

ScheduleData struct ScheduleData

type ScheduleLog

type ScheduleLog struct {
	LastData     ScheduleData
	HistoryDatas []ScheduleData
}

ScheduleLog struct ScheduleLog

type TaskBase

type TaskBase struct {
	Id               uint64
	TaskId           string
	UserId           string
	Status           int
	TaskType         string
	TaskStage        string
	TaskContext      string
	CrtRetryNum      int
	MaxRetryNum      int
	MaxRetryInterval int
	ScheduleLog      *ScheduleLog
	ContextIntf      interface{}
	Priority         int64
	OrderTime        int64
	CreateTime       time.Time
	ModifyTime       time.Time
}

TaskBase struct TaskBase

func (*TaskBase) Base

func (p *TaskBase) Base() *TaskBase

Base func get base struct

func (*TaskBase) ContextLoad

func (p *TaskBase) ContextLoad() error

ContextLoad context load

func (*TaskBase) CreateTask

func (p *TaskBase) CreateTask() (string, error)

CreateTask func create task

func (*TaskBase) HandleFailedMust

func (p *TaskBase) HandleFailedMust() error

HandleFailedMust if err, then change status from failed to processing

func (*TaskBase) HandleFinishError

func (p *TaskBase) HandleFinishError() error

HandleFinishError handle finish error

func (*TaskBase) HandleFinishMust

func (p *TaskBase) HandleFinishMust() error

HandleFinishMust handle finish HandleFinishMust

func (*TaskBase) SetContextLocal

func (p *TaskBase) SetContextLocal(data interface{})

SetContextLocal func set context local

func (*TaskBase) SetTask

func (p *TaskBase) SetTask() error

SetTask set task

type TaskHandler

type TaskHandler struct {
	TaskType string
	NewProc  func() TaskIntf // NewProc是一个函数,返回一个TaskIntf
}

TaskHandler struct TaskHandler

func GetHandler

func GetHandler(taskType string) (*TaskHandler, int)

GetHandler func get handler

type TaskIntf

type TaskIntf interface {
	ContextLoad() error
	HandleProcess() error
	SetTask() error
	HandleFinish()
	HandleFinishError() error
	Base() *TaskBase
	CreateTask() (string, error)
	HandleFailedMust() error
}

TaskIntf Task interface

func GetTask

func GetTask(taskId string) (TaskIntf, error)

GetTask func get task

func GetTaskInfoFromStorage

func GetTaskInfoFromStorage(storage *model.TaskData) (TaskIntf, error)

GetTaskInfoFromStorage func get task info from rpc

type TaskMgr

type TaskMgr struct {
	InternelTime  time.Duration
	TaskType      string
	ScheduleLimit int
}

TaskMgr struct short task mgr

func (*TaskMgr) Schedule

func (p *TaskMgr) Schedule()

Schedule func schedule

Jump to

Keyboard shortcuts

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