Documentation ¶
Index ¶
- Constants
- Variables
- type Scheduler
- func (s *Scheduler) Clear()
- func (s *Scheduler) DisableTaskByID(id int) error
- func (s *Scheduler) EnableTaskByID(id int) error
- func (s *Scheduler) GetDisableTasks() []*Task
- func (s *Scheduler) GetEnableTasks() []*Task
- func (s *Scheduler) GetTaskByID(id int) *Task
- func (s *Scheduler) GetTasks() []*Task
- func (s *Scheduler) NewScheduleTask(id int, name string, action func(v ...interface{}) error, signal chan int, ...) error
- func (s *Scheduler) RemoveTaskByID(id int) error
- func (s *Scheduler) RunAsync()
- type Task
Constants ¶
View Source
const ( TaskExecutionStatusOK = 0x0 TaskExecutionStatusFailed = 0x1 TaskExecutionStatusPending = 0x2 )
View Source
const (
SIGTASKTERM = 0x1
)
Goroutine task signals
Variables ¶
View Source
var ( //ErrorBadTimeFormat is rise when time format is bad for example create a task that run at 52 hour ErrorBadTimeFormat error = errors.New("bad Time Format") //ErrorTaskNotFound rised when no task found in the scheduler ErrorTaskNotFound error = errors.New("task not found in the scheduler") )
View Source
var DefaultScheduler = NewScheduler(log.New(os.Stdout, "Warning: ", log.Ldate|log.Ltime|log.Lshortfile), log.New(os.Stdout, "INFO: ", log.Ldate|log.Ltime|log.Lshortfile), log.New(os.Stdout, "Error: ", log.Ldate|log.Ltime|log.Lshortfile))
DefaultScheduler is the default scheduler without any log
Functions ¶
This section is empty.
Types ¶
type Scheduler ¶
type Scheduler struct { Tasks []*Task UpdateInterval int WarningLogger *log.Logger InfoLogger *log.Logger ErrorLogger *log.Logger }
Scheduler represent the scheduler
func NewScheduler ¶
NewScheduler is constructor of scheduler
func (*Scheduler) DisableTaskByID ¶
DisableTaskByID disable task on the scheduler but don't delete it
func (*Scheduler) EnableTaskByID ¶
EnableTaskByID enable a task that has been disabled
func (*Scheduler) GetDisableTasks ¶
GetDisableTasks return disable task
func (*Scheduler) GetEnableTasks ¶
GetEnableTasks return enabled task
func (*Scheduler) GetTaskByID ¶
func (*Scheduler) NewScheduleTask ¶
func (s *Scheduler) NewScheduleTask(id int, name string, action func(v ...interface{}) error, signal chan int, hour, minute, second int) error
NewScheduleTask create a new schedule task and add it in the scheduler
func (*Scheduler) RemoveTaskByID ¶
RemoveTaskByID remove task in the scheduler by it's ID
Click to show internal directories.
Click to hide internal directories.