manage

package
v1.5.5 Latest Latest
Warning

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

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

Documentation

Overview

Package manage

Package manage

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SimpleTask

func SimpleTask()

Types

type Manager

type Manager interface {
	// Logger 设置logger
	Logger(logger log.Log)
	// AddTimer 添加定时任务
	AddTimer(taskName string, args []interface{}, timer Timer)
	// AddInterval 添加间隔任务
	AddInterval(taskName string, args []interface{}, interval int)
	// AddDelay 添加延迟任务
	AddDelay(taskName string, args []interface{}, delayTime uint)
	// AddSimple 添加即时任务
	AddSimple(taskName string, args []interface{})
	// RegisterFixed 注册任务,包括:任务名称以及执行函数,函数类型必须是 funcType
	RegisterFixed(taskName string, fun funcType)
	// RegisterFlexible 推荐此方式
	// 注册任务,包括:任务名称以及执行函数,函数类型必须是 taskfunc(param ...interface{}) 或 自定义参数 taskfunc(i int, s string, arr []int)
	RegisterFlexible(taskName string, fun interface{})
	// UnRegister 反注册,删除执行器
	UnRegister(taskName string)
	// Run 启动任务管理器
	Run()
	// SetTaskEffectiveTime 设置任务的有效期,单位:秒 默认:60
	// 任务管理器启动有先后,在服务变更时,某个task可能在旧的的node不存在,因此执行不了,
	// 所以需要将任务重新添加到队列,但是需要兼容这个任务已下线,永远不能可能执行的情况
	// 因此需要指定此类任务有效时间,单位:秒 默认:60
	SetTaskEffectiveTime(second int64)
}

Manager 所有task管理器方法 1、所有任务必须注册才可调用 2、任务参数必须可序列化、反序列化 3、任务管理器只保证任务执行,业务逻辑报错需要业务处理

func NewManager

func NewManager(ctx context.Context, workPoolSize int, taskLabel string, registerIntervalMS int64, redisConn *redis.Redis) Manager

NewManager 创建任务管理器

func SingleTask

func SingleTask(workPoolSize int, taskLabel string, registerIntervalMS int64, redisConn *redis.Redis) Manager

SingleTask 创建TaskManager单例

type Timer

type Timer struct {
	Month   *int
	Day     *int
	Hour    *int
	Minutes *int
	Second  *int
}

Timer task timer config data nil 标识所有可能的参数,如:Second=nil,标识0~59秒

func NewTimer

func NewTimer() *Timer

func (*Timer) SetDay

func (t *Timer) SetDay(i int) *Timer

func (*Timer) SetHour

func (t *Timer) SetHour(i int) *Timer

func (*Timer) SetMinutes

func (t *Timer) SetMinutes(i int) *Timer

func (*Timer) SetMonth

func (t *Timer) SetMonth(i int) *Timer

func (*Timer) SetSecond

func (t *Timer) SetSecond(i int) *Timer

Jump to

Keyboard shortcuts

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