Documentation ¶
Index ¶
- type MapSorter
- type Option
- type Schedule
- type Task
- func (t *Task) GetNext(context.Context) time.Time
- func (t *Task) GetPrev(context.Context) time.Time
- func (t *Task) GetSpec(context.Context) string
- func (t *Task) GetStatus(context.Context) string
- func (t *Task) GetTimeout(context.Context) time.Duration
- func (t *Task) Run(ctx context.Context) error
- func (t *Task) SetCron(spec string)
- func (t *Task) SetNext(ctx context.Context, now time.Time)
- func (t *Task) SetPrev(ctx context.Context, now time.Time)
- type TaskFunc
- type TaskManager
- func (m *TaskManager) AddTask(taskname string, t Tasker)
- func (m *TaskManager) ClearTask()
- func (m *TaskManager) DeleteTask(taskname string)
- func (m *TaskManager) GracefulShutdown() <-chan struct{}
- func (m *TaskManager) Len() int
- func (m *TaskManager) StartTask()
- func (m *TaskManager) StopTask()
- func (t *TaskManager) WorkerStart() error
- func (t *TaskManager) WorkerStop() error
- type Tasker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MapSorter ¶ added in v2.3.3
MapSorter sort map for tasker
func NewMapSorter ¶ added in v2.3.3
NewMapSorter create new tasker map
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option interface
func TimeoutOption ¶ added in v2.3.3
TimeoutOption return a option to set timeout duration for task
type Schedule ¶
type Schedule struct { Second uint64 Minute uint64 Hour uint64 Day uint64 Month uint64 Week uint64 }
Schedule time taks schedule
type Task ¶ added in v2.3.3
type Task struct { Taskname string Spec *Schedule SpecStr string DoFunc TaskFunc Prev time.Time Next time.Time Timeout time.Duration // timeout duration Errlist []*taskerr // like errtime:errinfo ErrLimit int // max length for the errlist, 0 stand for no limit // contains filtered or unexported fields }
Task task struct It's not a thread-safe structure. Only nearest errors will be saved in ErrList
func (*Task) GetTimeout ¶ added in v2.3.3
GetTimeout get timeout duration of this task
func (*Task) SetCron ¶ added in v2.3.3
SetCron some signals:
*: any time ,: separate signal
-:duration
/n : do as n times of time duration
///////////////////////////////////////////////////////
0/30 * * * * * every 30s 0 43 21 * * * 21:43 0 15 05 * * * 05:15 0 0 17 * * * 17:00 0 0 17 * * 1 17:00 in every Monday 0 0,10 17 * * 0,2,3 17:00 and 17:10 in every Sunday, Tuesday and Wednesday 0 0-10 17 1 * * 17:00 to 17:10 in 1 min duration each time on the first day of month 0 0 0 1,15 * 1 0:00 on the 1st day and 15th day of month 0 42 4 1 * * 4:42 on the 1st day of month 0 0 21 * * 1-6 21:00 from Monday to Saturday 0 0,10,20,30,40,50 * * * * every 10 min duration 0 */10 * * * * every 10 min duration 0 * 1 * * * 1:00 to 1:59 in 1 min duration each time 0 0 1 * * * 1:00 0 0 */1 * * * 0 min of hour in 1 hour duration 0 0 * * * * 0 min of hour in 1 hour duration 0 2 8-20/3 * * * 8:02, 11:02, 14:02, 17:02, 20:02 0 30 5 1,15 * * 5:30 on the 1st day and 15th day of month
type TaskManager ¶ added in v2.3.3
type TaskManager struct {
// contains filtered or unexported fields
}
func NewTaskManager ¶ added in v2.3.3
func NewTaskManager() *TaskManager
func (*TaskManager) AddTask ¶ added in v2.3.3
func (m *TaskManager) AddTask(taskname string, t Tasker)
AddTask add task with name
func (*TaskManager) ClearTask ¶ added in v2.3.3
func (m *TaskManager) ClearTask()
ClearTask clear all tasks
func (*TaskManager) DeleteTask ¶ added in v2.3.3
func (m *TaskManager) DeleteTask(taskname string)
DeleteTask delete task with name
func (*TaskManager) GracefulShutdown ¶ added in v2.3.3
func (m *TaskManager) GracefulShutdown() <-chan struct{}
GracefulShutdown wait all task done
func (*TaskManager) Len ¶ added in v2.3.3
func (m *TaskManager) Len() int
func (*TaskManager) StartTask ¶ added in v2.3.3
func (m *TaskManager) StartTask()
StartTask start all tasks
func (*TaskManager) StopTask ¶ added in v2.3.3
func (m *TaskManager) StopTask()
StopTask stop all tasks
func (*TaskManager) WorkerStart ¶ added in v2.3.3
func (t *TaskManager) WorkerStart() error
func (*TaskManager) WorkerStop ¶ added in v2.3.3
func (t *TaskManager) WorkerStop() error
type Tasker ¶ added in v2.3.3
type Tasker interface { GetSpec(ctx context.Context) string GetStatus(ctx context.Context) string Run(ctx context.Context) error SetNext(context.Context, time.Time) GetNext(ctx context.Context) time.Time SetPrev(context.Context, time.Time) GetPrev(ctx context.Context) time.Time GetTimeout(ctx context.Context) time.Duration }
Tasker task interface
Click to show internal directories.
Click to hide internal directories.