Documentation
¶
Index ¶
- Variables
- type Group
- type Job
- type LockFunc
- type Locker
- type ScheduleFunc
- type Worker
- func (w *Worker) ByCronSpec(spec string) *Worker
- func (w *Worker) BySchedule(s ScheduleFunc) *Worker
- func (w *Worker) ByTicker(period time.Duration) *Worker
- func (w *Worker) ByTimer(period time.Duration) *Worker
- func (w *Worker) Run(ctx context.Context)
- func (w *Worker) RunOnce(ctx context.Context)
- func (w *Worker) SetImmediately(executeOnRun bool) *Worker
- func (w *Worker) WithDone(done func()) *Worker
- func (w *Worker) WithLock(l Locker) *Worker
Constants ¶
This section is empty.
Variables ¶
var ErrGroupStopped = errors.New("group is already stopped")
ErrGroupStopped group error message already stopped
Functions ¶
This section is empty.
Types ¶
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group of workers controlling background jobs execution allows graceful stop all running background jobs
type ScheduleFunc ¶
ScheduleFunc is job wrapper for implement job run schedule
func ByCronSchedule ¶
func ByCronSchedule(schedule string) ScheduleFunc
ByCronSchedule returns job wrapper func for run job by cron schedule using robfig/cron parser for parse cron spec. If schedule spec not valid throw panic, shit happens.
func ByTicker ¶
func ByTicker(period time.Duration) ScheduleFunc
ByTicker returns func which run Worker by ticker each period duration
func ByTimer ¶
func ByTimer(period time.Duration) ScheduleFunc
ByTimer returns job wrapper func for run job each period duration after previous run completed
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker is builder for job with optional schedule and exclusive control
func (*Worker) ByCronSpec ¶
ByCronSpec set schedule job wrapper by cron spec
func (*Worker) BySchedule ¶
func (w *Worker) BySchedule(s ScheduleFunc) *Worker
BySchedule set schedule wrapper func for job
func (*Worker) SetImmediately ¶
SetImmediately set execute job on Run setting
