Versions in this module Expand all Collapse all v3 v3.12.5 Nov 8, 2024 v3.12.4 Nov 8, 2024 Changes in this version + const LimitModeReschedule + const LimitModeWait + var ErrCronJobInvalid = fmt.Errorf("gocron: CronJob: invalid crontab") + var ErrCronJobParse = fmt.Errorf("gocron: CronJob: crontab parse failure") + var ErrDailyJobAtTimeNil = fmt.Errorf("gocron: DailyJob: atTime within atTimes must not be nil") + var ErrDailyJobAtTimesNil = fmt.Errorf("gocron: DailyJob: atTimes must not be nil") + var ErrDailyJobHours = fmt.Errorf("gocron: DailyJob: atTimes hours must be between 0 and 23 inclusive") + var ErrDailyJobMinutesSeconds = fmt.Errorf(...) + var ErrDailyJobZeroInterval = fmt.Errorf("gocron: DailyJob: interval must be greater than 0") + var ErrDurationJobIntervalZero = fmt.Errorf("gocron: DurationJob: time interval is 0") + var ErrDurationRandomJobMinMax = fmt.Errorf(...) + var ErrEventListenerFuncNil = fmt.Errorf("gocron: eventListenerFunc must not be nil") + var ErrJobNotFound = fmt.Errorf("gocron: job not found") + var ErrJobRunNowFailed = fmt.Errorf("gocron: Job: RunNow: scheduler unreachable") + var ErrMonthlyJobAtTimeNil = fmt.Errorf("gocron: MonthlyJob: atTime within atTimes must not be nil") + var ErrMonthlyJobAtTimesNil = fmt.Errorf("gocron: MonthlyJob: atTimes must not be nil") + var ErrMonthlyJobDays = fmt.Errorf(...) + var ErrMonthlyJobDaysNil = fmt.Errorf("gocron: MonthlyJob: daysOfTheMonth must not be nil") + var ErrMonthlyJobHours = fmt.Errorf("gocron: MonthlyJob: atTimes hours must be between 0 and 23 inclusive") + var ErrMonthlyJobMinutesSeconds = fmt.Errorf(...) + var ErrMonthlyJobZeroInterval = fmt.Errorf("gocron: MonthlyJob: interval must be greater than 0") + var ErrNewJobTaskNil = fmt.Errorf("gocron: NewJob: Task must not be nil") + var ErrNewJobTaskNotFunc = fmt.Errorf("gocron: NewJob: Task.Function must be of kind reflect.Func") + var ErrNewJobWrongNumberOfParameters = fmt.Errorf("gocron: NewJob: Number of provided parameters does not match expected") + var ErrNewJobWrongTypeOfParameters = fmt.Errorf("gocron: NewJob: Type of provided parameters does not match expected") + var ErrOneTimeJobStartDateTimePast = fmt.Errorf("gocron: OneTimeJob: start must not be in the past") + var ErrPanicRecovered = fmt.Errorf("gocron: panic recovered") + var ErrStartTimeLaterThanEndTime = fmt.Errorf("gocron: WithStartDateTime: start must not be later than end") + var ErrStopExecutorTimedOut = fmt.Errorf("gocron: timed out waiting for executor to stop") + var ErrStopJobsTimedOut = fmt.Errorf("gocron: timed out waiting for jobs to finish") + var ErrStopSchedulerTimedOut = fmt.Errorf("gocron: timed out waiting for scheduler to stop") + var ErrStopTimeEarlierThanStartTime = fmt.Errorf("gocron: WithStopDateTime: end must not be earlier than start") + var ErrWeeklyJobAtTimeNil = fmt.Errorf("gocron: WeeklyJob: atTime within atTimes must not be nil") + var ErrWeeklyJobAtTimesNil = fmt.Errorf("gocron: WeeklyJob: atTimes must not be nil") + var ErrWeeklyJobDaysOfTheWeekNil = fmt.Errorf("gocron: WeeklyJob: daysOfTheWeek must not be nil") + var ErrWeeklyJobHours = fmt.Errorf("gocron: WeeklyJob: atTimes hours must be between 0 and 23 inclusive") + var ErrWeeklyJobMinutesSeconds = fmt.Errorf(...) + var ErrWeeklyJobZeroInterval = fmt.Errorf("gocron: WeeklyJob: interval must be greater than 0") + var ErrWithClockNil = fmt.Errorf("gocron: WithClock: clock must not be nil") + var ErrWithDistributedElectorNil = fmt.Errorf("gocron: WithDistributedElector: elector must not be nil") + var ErrWithDistributedJobLockerNil = fmt.Errorf("gocron: WithDistributedJobLocker: locker must not be nil") + var ErrWithDistributedLockerNil = fmt.Errorf("gocron: WithDistributedLocker: locker must not be nil") + var ErrWithFailedToAddJob = fmt.Errorf("gocron: WithAddJob: fail to add job") + var ErrWithIdentifierNil = fmt.Errorf("gocron: WithIdentifier: identifier must not be nil") + var ErrWithLimitConcurrentJobsZero = fmt.Errorf("gocron: WithLimitConcurrentJobs: limit must be greater than 0") + var ErrWithLocationNil = fmt.Errorf("gocron: WithLocation: location must not be nil") + var ErrWithLoggerNil = fmt.Errorf("gocron: WithLogger: logger must not be nil") + var ErrWithMonitorNil = fmt.Errorf("gocron: WithMonitor: monitor must not be nil") + var ErrWithNameEmpty = fmt.Errorf("gocron: WithName: name must not be empty") + var ErrWithStartDateTimePast = fmt.Errorf("gocron: WithStartDateTime: start must not be in the past") + var ErrWithStopDateTimePast = fmt.Errorf("gocron: WithStopDateTime: end must not be in the past") + var ErrWithStopTimeoutZeroOrNegative = fmt.Errorf("gocron: WithStopTimeout: timeout must be greater than 0") + type AtTime func() atTime + func NewAtTime(hours, minutes, seconds uint) AtTime + type AtTimes func() []AtTime + func NewAtTimes(atTime AtTime, atTimes ...AtTime) AtTimes + type DaysOfTheMonth func() days + func NewDaysOfTheMonth(day int, moreDays ...int) DaysOfTheMonth + type Elector interface + IsLeader func(context.Context) error + type EventListener func(*internalJob) error + func AfterJobRuns(...) EventListener + func AfterJobRunsWithError(eventListenerFunc func(jobID uuid.UUID, jobName string, err error, ...)) EventListener + func AfterJobRunsWithPanic(eventListenerFunc func(jobID uuid.UUID, jobName string, recoverData any)) EventListener + func AfterJobStopTime(eventListenerFunc func(jobID uuid.UUID, jobName string)) EventListener + func AfterLockError(eventListenerFunc func(jobID uuid.UUID, jobName string, err error)) EventListener + func AfterOneTimeJobAllRunComplete(eventListenerFunc func(jobID uuid.UUID, jobName string)) EventListener + func BeforeJobRuns(eventListenerFunc func(jobID uuid.UUID, jobName string) interface{}) EventListener + func BeforeJobStartTime(eventListenerFunc func(jobID uuid.UUID, jobName string)) EventListener + func OnJobLimitedRunsComplete(eventListenerFunc func(jobID uuid.UUID, jobName string)) EventListener + type Job interface + ID func() uuid.UUID + LastRun func() (time.Time, error) + Name func() string + NextRun func() (time.Time, error) + NextRuns func(int) ([]time.Time, error) + RunNow func() error + Tags func() []string + type JobDefinition interface + func CronJob(crontab string, withSeconds bool) JobDefinition + func DailyJob(interval uint, atTimes AtTimes) JobDefinition + func DurationJob(duration time.Duration) JobDefinition + func DurationRandomJob(minDuration, maxDuration time.Duration) JobDefinition + func MonthlyJob(interval uint, daysOfTheMonth DaysOfTheMonth, atTimes AtTimes) JobDefinition + func OneTimeJob(startAt OneTimeJobStartAtOption) JobDefinition + func WeeklyJob(interval uint, daysOfTheWeek Weekdays, atTimes AtTimes) JobDefinition + type JobOption func(*internalJob, time.Time) error + func AutoRemove(afterJobRunCompleteRemove bool) JobOption + func WithDistributedJobLocker(locker Locker) JobOption + func WithEventListeners(eventListeners ...EventListener) JobOption + func WithIdentifier(id uuid.UUID) JobOption + func WithLimitedRuns(limit uint) JobOption + func WithName(name string) JobOption + func WithSingletonMode(mode LimitMode) JobOption + func WithStartAt(option StartAtOption) JobOption + func WithStopAt(option StopAtOption) JobOption + func WithTags(tags ...string) JobOption + type JobStatus string + const Fail + const Rescheduled + const SingletonRescheduled + const Skip + const Success + type LimitMode int + type Lock interface + Unlock func(ctx context.Context) error + type Locker interface + Lock func(ctx context.Context, key string) (Lock, error) + type LogLevel int + const LogLevelDebug + const LogLevelError + const LogLevelInfo + const LogLevelWarn + type Logger interface + Debug func(msg string, args ...any) + Error func(msg string, args ...any) + Info func(msg string, args ...any) + Warn func(msg string, args ...any) + func NewLogger(level LogLevel) Logger + type Monitor interface + IncrementJob func(id uuid.UUID, name string, tags []string, status JobStatus) + RecordJobTiming func(startTime, endTime time.Time, id uuid.UUID, name string, tags []string) + type OneTimeJobStartAtOption func(*internalJob) []time.Time + func OneTimeJobStartDateTime(start time.Time) OneTimeJobStartAtOption + func OneTimeJobStartDateTimes(times ...time.Time) OneTimeJobStartAtOption + func OneTimeJobStartImmediately() OneTimeJobStartAtOption + type Scheduler interface + Jobs func() []Job + JobsWaitingInQueue func() int + NewJob func(JobDefinition, Task, ...JobOption) (Job, error) + RemoveByTags func(...string) + RemoveJob func(uuid.UUID) error + Shutdown func() error + Start func() + StopJobs func() error + Update func(uuid.UUID, JobDefinition, Task, ...JobOption) (Job, error) + func NewScheduler(options ...SchedulerOption) (Scheduler, error) + type SchedulerOption func(*scheduler) error + func WithClock(clock clockwork.Clock) SchedulerOption + func WithDistributedElector(elector Elector) SchedulerOption + func WithDistributedLocker(locker Locker) SchedulerOption + func WithGlobalJobOptions(jobOptions ...JobOption) SchedulerOption + func WithLimitConcurrentJobs(limit uint, mode LimitMode, jobLimitModeCanOverride bool) SchedulerOption + func WithLocation(location *time.Location) SchedulerOption + func WithLogger(logger Logger) SchedulerOption + func WithMonitor(monitor Monitor) SchedulerOption + func WithStopTimeout(timeout time.Duration) SchedulerOption + type StartAtOption func(*internalJob, time.Time) error + func WithStartDateTime(start time.Time) StartAtOption + func WithStartImmediately() StartAtOption + type StopAtOption func(*internalJob, time.Time) error + func WithStopDateTime(end time.Time) StopAtOption + type Task func() task + func NewTask(function any, parameters ...any) Task + type Weekdays func() []time.Weekday + func NewWeekdays(weekday time.Weekday, weekdays ...time.Weekday) Weekdays