Documentation
¶
Index ¶
- Variables
- func CallMethod(task *tasks.TaskJob) (err error)
- func UnmarshalTask(data []byte) (*tasks.TaskJob, error)
- func WithCallback(s string) func(*Options)
- func WithClearArchived(second int) func(*Options)
- func WithGroup(s string) func(*Options)
- func WithHandler(fun func(ctx context.Context, p Payload) error) func(*Options)
- func WithHandlerNeedWorker(fun func(worker Worker, ctx context.Context, p Payload) error) func(*Options)
- func WithMaxRetry(count int) func(*Options)
- func WithRedisPeriodKey(s string) func(*Options)
- func WithRedisUri(s string) func(*Options)
- func WithRetention(second int) func(*Options)
- func WithRunAt(at time.Time) func(*RunOptions)
- func WithRunCtx(ctx context.Context) func(*RunOptions)
- func WithRunExpr(s string) func(*RunOptions)
- func WithRunGroup(s string) func(*RunOptions)
- func WithRunIn(in time.Duration) func(*RunOptions)
- func WithRunMaxRetry(count int) func(*RunOptions)
- func WithRunNow(flag bool) func(*RunOptions)
- func WithRunPayload(s []byte) func(*RunOptions)
- func WithRunReplace(flag bool) func(*RunOptions)
- func WithRunRetention(second int) func(*RunOptions)
- func WithRunTimeout(second int) func(*RunOptions)
- func WithRunUuid(s string) func(*RunOptions)
- func WithTimeout(second int) func(*Options)
- type Options
- type Payload
- type Process
- type RunOptions
- type Scheduled
- type Tasks
- func (tk Tasks) CheckFuncName(funcName string) (exists bool)
- func (tk Tasks) Cron(options ...func(*RunOptions)) error
- func (tk Tasks) GetTaskJobNameList() (res map[string]string)
- func (tk Tasks) Once(options ...func(*RunOptions)) error
- func (tk Tasks) ParseParameters(parseData string) (params []interface{}, err error)
- func (tk Tasks) Remove(ctx context.Context, uid string) error
- type Worker
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrUuidNil = fmt.Errorf("uuid is empty") ErrRedisNil = fmt.Errorf("redis is empty") ErrRedisInvalid = fmt.Errorf("redis is invalid") ErrExprInvalid = fmt.Errorf("expr is invalid") ErrSaveCron = fmt.Errorf("save cron failed") ErrHttpCallbackInvalidStatusCode = fmt.Errorf("http callback invalid status code") )
Functions ¶
func UnmarshalTask ¶
UnmarshalTask 解析TaskJob,使用自定义JSON解析来处理类型问题
func WithClearArchived ¶
WithClearArchived 清除已存档任务的间隔,默认为 300 秒
func WithHandler ¶
WithHandler 设置任务的回调处理器
func WithHandlerNeedWorker ¶
func WithHandlerNeedWorker(fun func(worker Worker, ctx context.Context, p Payload) error) func(*Options)
WithHandlerNeedWorker 设置需要Worker参数的任务处理函数
func WithRedisPeriodKey ¶
WithRedisPeriodKey 设置redis周期任务key
func WithRedisUri ¶
WithRedisUri 设置redis连接地址,默认值redis://127.0.0.1:6379/0
func WithRetention ¶
WithRetention 成功任务存储时间,默认 60 秒,如果提供此选项,任务将在成功处理后作为已完成任务存储
func WithRunExpr ¶
func WithRunExpr(s string) func(*RunOptions)
WithRunExpr Cron表达式, 最小单位1分钟, 参见gorhill/cronexpr
func WithRunMaxRetry ¶
func WithRunMaxRetry(count int) func(*RunOptions)
WithRunMaxRetry 最大重试次数, 任务回调发生error会重试,默认3次
func WithRunReplace ¶
func WithRunReplace(flag bool) func(*RunOptions)
WithRunReplace 当uid重复时,删除旧的并创建新的
func WithRunRetention ¶
func WithRunRetention(second int) func(*RunOptions)
WithRunRetention 任务过期时间,默认60秒
Types ¶
type Payload ¶
type Process ¶
type Process interface {
GetTopic() string // 获取消费主题
Handle(ctx context.Context, p Payload) (err error) // 处理过程的方法
}
Process 任务具体处理过程接口,实现该接口即可加入到任务队列中
type RunOptions ¶
type RunOptions struct {
// contains filtered or unexported fields
}
type Scheduled ¶
type Scheduled struct {
// contains filtered or unexported fields
}
Scheduled 任务调度器
func RegisterProcess ¶
type Tasks ¶
type Tasks struct {
// contains filtered or unexported fields
}
func TasksInstance ¶
func TasksInstance() *Tasks
func (Tasks) CheckFuncName ¶
CheckFuncName 检查方法名是否存在
func (Tasks) Cron ¶
func (tk Tasks) Cron(options ...func(*RunOptions)) error
Cron 注册一个任务以由cron表达式运行。
func (Tasks) GetTaskJobNameList ¶
GetTaskJobNameList 获取任务可用方法名列表。
func (Tasks) ParseParameters ¶
ParseParameters 解析参数
Click to show internal directories.
Click to hide internal directories.