Documentation ¶
Index ¶
- func Retry(ctx context.Context, maxRetry int, callback RetryCallback, ...) (err error)
- type Handler
- type Job
- type JobHandler
- type JobQueue
- type RetryBackoff
- type RetryCallback
- type Task
- type TaskConfig
- func (c *TaskConfig) After(interval time.Duration) *TaskConfig
- func (c *TaskConfig) At(hour, minute int) *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) 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
- type TaskRunner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Retry ¶ added in v0.1.0
func Retry( ctx context.Context, maxRetry int, callback RetryCallback, backoff RetryBackoff, errHook func(err error), ) (err error)
Types ¶
type JobQueue ¶ added in v0.1.0
type JobQueue struct {
// contains filtered or unexported fields
}
func NewJobQueue ¶ added in v0.1.0
func (*JobQueue) Queue ¶ added in v0.1.0
func (q *JobQueue) Queue(job JobHandler, arg ...any)
Queue adds a new job to the queue
type RetryBackoff ¶ added in v0.1.0
type RetryCallback ¶ added in v0.1.0
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 ¶ added in v0.0.15
func Every(interval ...int) *TaskConfig
Every begins configuring a task. supply zero or one intervals. no intervals will be counted as 1
func Once ¶ added in v0.0.15
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) 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.
type TaskRunner ¶ added in v0.1.0
type TaskRunner struct {
// contains filtered or unexported fields
}
TaskRunner is responsible for running the task given to them
func (*TaskRunner) Close ¶ added in v0.1.0
func (r *TaskRunner) Close() error
Close closes the task runner.