task

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler func(*Task) error

任务执行函数。 特别注意,如果ttl不是0。但是因为某些原因不需要执行下一次操作了。则需要返回nil 比如。需要对某特定条件数据执行某个操作。在这之前自然是会检查这个数据是否存在或者是否能被操作等。 如果没有拿到这条数据,则直接返回nil

type Task

type Task struct {
	Key   string                 // system_name/job_id
	Tag   string                 // Tag匹配Handler,无Tag的Task将不会被执行
	Args  map[string]interface{} // 任务参数
	Delay int64                  // 延迟时间

	TTL      int64 //如果执行失败,下一次重复的时间
	Retry    int   //已经重试的次数
	RetryMax int   //最大重试次数
}

func UnmarshalJson

func UnmarshalJson(j string) (*Task, error)

func (*Task) MarshalJson

func (t *Task) MarshalJson() string

func (*Task) Sn

func (t *Task) Sn() uint64

把key变成sn。很多情况下,都是sn设为key的

func (*Task) Subkey

func (t *Task) Subkey() string

Jump to

Keyboard shortcuts

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