Documentation ¶
Index ¶
- type Handler
- type RunnerContainer
- type Task
- type TaskConfig
- func (c *TaskConfig) After(interval time.Duration) *TaskConfig
- func (c *TaskConfig) At(hour, minute int) *TaskConfig
- func (c *TaskConfig) Clone() *TaskConfig
- func (c *TaskConfig) Day() *TaskConfig
- func (c *TaskConfig) Days() *TaskConfig
- func (c *TaskConfig) Do(f Handler, args ...any) (r *TaskRunner, err error)
- func (c *TaskConfig) DoContext(ctx context.Context, f Handler, args ...any) (r *TaskRunner, err error)
- func (c *TaskConfig) Friday() *TaskConfig
- func (c *TaskConfig) From(from time.Time) *TaskConfig
- func (c *TaskConfig) Hour() *TaskConfig
- func (c *TaskConfig) Hours() *TaskConfig
- func (c *TaskConfig) Millisecond() *TaskConfig
- func (c *TaskConfig) Milliseconds() *TaskConfig
- func (c *TaskConfig) Minute() *TaskConfig
- func (c *TaskConfig) Minutes() *TaskConfig
- func (c *TaskConfig) Monday() *TaskConfig
- func (c *TaskConfig) OnBeforeStart(f Handler) *TaskConfig
- func (c *TaskConfig) OnFinish(f Handler) *TaskConfig
- func (c *TaskConfig) Saturday() *TaskConfig
- func (c *TaskConfig) Second() *TaskConfig
- func (c *TaskConfig) Seconds() *TaskConfig
- func (c *TaskConfig) Sunday() *TaskConfig
- func (c *TaskConfig) Thursday() *TaskConfig
- func (c *TaskConfig) To(to time.Time) *TaskConfig
- func (c *TaskConfig) Tuesday() *TaskConfig
- func (c *TaskConfig) Wednesday() *TaskConfig
- func (c *TaskConfig) Week() *TaskConfig
- func (c *TaskConfig) Weeks() *TaskConfig
- func (c *TaskConfig) WithName(name string) *TaskConfig
- type TaskRunner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RunnerContainer ¶
type RunnerContainer struct { Configs []*TaskConfig Callbacks []Handler Runners []*TaskRunner }
func NewRunnerContainer ¶
func NewRunnerContainer() *RunnerContainer
func (*RunnerContainer) Append ¶
func (r *RunnerContainer) Append(cfg *TaskConfig, cb Handler)
func (*RunnerContainer) CloseAll ¶
func (r *RunnerContainer) CloseAll() error
func (*RunnerContainer) StartAll ¶
func (r *RunnerContainer) StartAll() error
func (*RunnerContainer) StartAllContext ¶
func (r *RunnerContainer) StartAllContext(ctx context.Context) error
type Task ¶
type Task struct {
// contains filtered or unexported fields
}
Task is passed to task handlers and contains the payload
type TaskConfig ¶
type TaskConfig struct {
// contains filtered or unexported fields
}
TaskConfig is responsible for configuring a task and scheduling it.
func Every ¶
func Every(interval ...int) *TaskConfig
Every begins configuring a task. supply zero or one intervals. no intervals will be counted as 1
func Once ¶
func Once() *TaskConfig
Once begins configuring a task. sets the task to run only once. use Config.After or TaskConfig.From to set the time.
func (*TaskConfig) After ¶
func (c *TaskConfig) After(interval time.Duration) *TaskConfig
After starts the task after the specified duration. Short hand for From(time.Now().Add(interval))
func (*TaskConfig) At ¶
func (c *TaskConfig) At(hour, minute int) *TaskConfig
At sets the time of day to run the task.
func (*TaskConfig) Do ¶
func (c *TaskConfig) Do(f Handler, args ...any) (r *TaskRunner, err error)
Do run the task with the supplied payload in a new goroutine.
func (*TaskConfig) DoContext ¶
func (c *TaskConfig) DoContext(ctx context.Context, f Handler, args ...any) (r *TaskRunner, err error)
DoContext run the task with the supplied payload in a new goroutine.
func (*TaskConfig) Friday ¶
func (c *TaskConfig) Friday() *TaskConfig
Friday sets the unit to weeks and only runs on Fridays.
func (*TaskConfig) From ¶
func (c *TaskConfig) From(from time.Time) *TaskConfig
From sets the run time of the task.
func (*TaskConfig) Millisecond ¶
func (c *TaskConfig) Millisecond() *TaskConfig
Millisecond sets the interval to milliseconds.
func (*TaskConfig) Milliseconds ¶
func (c *TaskConfig) Milliseconds() *TaskConfig
Milliseconds is same as Millisecond.
func (*TaskConfig) Minute ¶
func (c *TaskConfig) Minute() *TaskConfig
Minute sets the interval to minutes.
func (*TaskConfig) Monday ¶
func (c *TaskConfig) Monday() *TaskConfig
Monday sets the unit to weeks and only runs on Mondays.
func (*TaskConfig) OnBeforeStart ¶
func (c *TaskConfig) OnBeforeStart(f Handler) *TaskConfig
OnBeforeStart sets the handler to be called before the task starts.
func (*TaskConfig) OnFinish ¶
func (c *TaskConfig) OnFinish(f Handler) *TaskConfig
OnFinish sets the finish handler for the task.
func (*TaskConfig) Saturday ¶
func (c *TaskConfig) Saturday() *TaskConfig
Saturday sets the unit to weeks and only runs on Saturdays.
func (*TaskConfig) Second ¶
func (c *TaskConfig) Second() *TaskConfig
Second sets the interval to seconds.
func (*TaskConfig) Sunday ¶
func (c *TaskConfig) Sunday() *TaskConfig
Sunday sets the unit to weeks and only runs on Sundays.
func (*TaskConfig) Thursday ¶
func (c *TaskConfig) Thursday() *TaskConfig
Thursday sets the unit to weeks and only runs on Thursdays.
func (*TaskConfig) To ¶
func (c *TaskConfig) To(to time.Time) *TaskConfig
To sets the end time of the task.
func (*TaskConfig) Tuesday ¶
func (c *TaskConfig) Tuesday() *TaskConfig
Tuesday sets the unit to weeks and only runs on Tuesdays.
func (*TaskConfig) Wednesday ¶
func (c *TaskConfig) Wednesday() *TaskConfig
Wednesday sets the unit to weeks and only runs on Wednesdays.
func (*TaskConfig) WithName ¶
func (c *TaskConfig) WithName(name string) *TaskConfig
type TaskRunner ¶
type TaskRunner struct {
// contains filtered or unexported fields
}
TaskRunner is responsible for running the task given to them