itask

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoTask = errors.New("ErrNoTask")

Functions

This section is empty.

Types

type ITask

type ITask interface {
	GetID() any // 唯一标识,大部分是主键
	GetUpdateTime() time.Time
	GetCreateTime() time.Time
	SetUpdateTime(time.Time)
	SetCreateTime(time.Time)
	GetType() uint32 // 标识任务类型,某一类的任务,需要按照添加顺序执行,比如充值任务
	IsOrder() bool   // 有序
}

type ITaskSerialize

type ITaskSerialize interface {
	// 初始化,用于将异常关闭的任务,状态重置等作用
	Init() error
	// 添加任务
	Add(ITask) error
	// 下一个任务,按照UpdateTime顺序获取task,排除某一类任务,有些任务需要按照顺序执行
	// 先添加的先获取,获取后更新UpdateTime,防止一个任务一直获取,阻塞死任务
	Next(exclude_t ...uint32) (ITask, error)
	// 下一个任务,按照CreateTime顺序获取task
	// 同一类任务,先添加的先获取,自然有阻塞死的情况,mgr里面处理
	NextByType(t uint32) (ITask, error)
	// 删除任务,任务执行完毕需要删除
	Remove(ITask) error
	// 任务状态还原。eg:如果任务出错,需要将状态还原,等待下次执行
	UpdateStatus2Init(ITask) error
	// 某一类有类型有顺序限制的
	HasNext(exclude_t ...uint32) (bool, error)
}

Jump to

Keyboard shortcuts

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