Documentation ¶
Index ¶
- type BuildTaskControllerOption
- func WithBlock() BuildTaskControllerOption
- func WithJobHandler(fn func(ctx context.Context, currentJob *Job) error) BuildTaskControllerOption
- func WithRedisKey(key string) BuildTaskControllerOption
- func WithTimeoutJobHandler(fn func(ctx context.Context, currentJob *Job) error) BuildTaskControllerOption
- type Job
- type JobOption
- type TaskController
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BuildTaskControllerOption ¶
type BuildTaskControllerOption func(tc *TaskController) error
func WithJobHandler ¶
func WithJobHandler(fn func(ctx context.Context, currentJob *Job) error) BuildTaskControllerOption
WithJobHandler set job handler.
func WithRedisKey ¶
func WithRedisKey(key string) BuildTaskControllerOption
WithRedisKey set task controller redis key.
func WithTimeoutJobHandler ¶
func WithTimeoutJobHandler(fn func(ctx context.Context, currentJob *Job) error) BuildTaskControllerOption
WithTimeoutJobHandler set timeout job handler.
type TaskController ¶
type TaskController struct { // 任务处理函数, 任务中心将会调用该函数处理所有的 Job JobHandler func(ctx context.Context, currentJob *Job) error // 超时任务处理函数 TimeoutJobHandler func(ctx context.Context, currentJob *Job) error // contains filtered or unexported fields }
func NewTaskController ¶
func NewTaskController(rc *redis.Client, interval time.Duration, opts ...BuildTaskControllerOption) (*TaskController, error)
NewTaskController build a new task controller.
func (*TaskController) AddJob ¶
func (tc *TaskController) AddJob(beginAt time.Time, payload []byte, opts ...JobOption) (string, error)
AddJob add a new job to task controller.
func (*TaskController) ListJobs ¶
func (tc *TaskController) ListJobs() ([]*Job, error)
ListJobs list all jobs.
func (*TaskController) RemoveJobs ¶
func (tc *TaskController) RemoveJobs(jobIDs ...string) (int64, error)
RemoveJobs remove jobs.
Click to show internal directories.
Click to hide internal directories.