Documentation ¶
Index ¶
- type Schedule
- func (s *Schedule) GetTask(n string) *Task
- func (s *Schedule) GetTasks() []*Task
- func (s *Schedule) IsStandBy() bool
- func (s *Schedule) IsTaskStandBy(t *Task) bool
- func (s *Schedule) NewTask(n string, i time.Duration, jitter time.Duration, ...) error
- func (s *Schedule) NewTaskString(n, i string, jitter time.Duration, f func() (map[string]*matrix.Matrix, error), ...) error
- func (s *Schedule) NextDue() time.Duration
- func (s *Schedule) Recover()
- func (s *Schedule) SetStandByMode(t *Task, i time.Duration)
- func (s *Schedule) SetStandByModeMax(t *Task, i time.Duration)
- func (s *Schedule) Sleep()
- func (s *Schedule) Wait() <-chan time.Time
- type Task
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Schedule ¶
type Schedule struct {
// contains filtered or unexported fields
}
Schedule contains a collection of tasks and the current state of the schedule
func (*Schedule) IsStandBy ¶
IsStandBy tells if schedule is in IsStandBy. If false, Schedule is in "normal" mode
func (*Schedule) IsTaskStandBy ¶
IsTaskStandBy tells if a task in schedule is in IsStandBy.
func (*Schedule) NewTask ¶
func (s *Schedule) NewTask(n string, i time.Duration, jitter time.Duration, f func() (map[string]*matrix.Matrix, error), runNow bool, identifier string) error
NewTask creates new task named n with interval i. If f is not nil, f will be called to execute task when task.Run() is called. Task name n should be unique. Interval i should be positive. The order in which tasks are added is maintained: GetTasks() will return tasks in FIFO order.
func (*Schedule) NewTaskString ¶
func (s *Schedule) NewTaskString(n, i string, jitter time.Duration, f func() (map[string]*matrix.Matrix, error), runNow bool, identifier string) error
NewTaskString creates a new task, the interval is parsed from string i
func (*Schedule) NextDue ¶
NextDue tells duration until at least one task is due If no tasks are scheduled, NextDue returns an arbitrary long duration (This is useful for collectors that run background jobs and need to wait indefinitely).
func (*Schedule) Recover ¶
func (s *Schedule) Recover()
Recover undoes StandbyMode and restores normal state of the Schedule
func (*Schedule) SetStandByMode ¶
SetStandByMode initializes StandbyMode: Schedule will suspend all tasks until the critical task t has succeeded. The temporary interval i will be used for the task until the Schedule recovers to normal mode.
func (*Schedule) SetStandByModeMax ¶
SetStandByModeMax initializes StandbyMode: Schedule will suspend all tasks until the critical task t has succeeded. The amount of time to standby will be the maximum of the task's current interval and i. That interval will be used for the task until the Schedule recovers to normal mode.
type Task ¶
type Task struct { Name string // name of the task // contains filtered or unexported fields }
Task represents a scheduled task
func (*Task) GetDuration ¶
GetDuration tells duration of executing the task it assumes that the task just completed
func (*Task) GetInterval ¶
GetInterval tells the scheduled interval of the task