mirror of https://github.com/go-co-op/gocron.git
feat: expose default cron implementation (#906)
This commit is contained in:
parent
f4c6d141a9
commit
7a1855ef7a
|
|
@ -348,6 +348,14 @@ func ExampleMonthlyJob() {
|
|||
)
|
||||
}
|
||||
|
||||
func ExampleNewDefaultCron() {
|
||||
c := gocron.NewDefaultCron(true)
|
||||
err := c.IsValid("* * * * * *", time.Local, time.Now())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func ExampleNewScheduler() {
|
||||
s, _ := gocron.NewScheduler()
|
||||
defer func() { _ = s.Shutdown() }()
|
||||
|
|
|
|||
9
job.go
9
job.go
|
|
@ -140,6 +140,15 @@ func newDefaultCronImplementation(withSeconds bool) Cron {
|
|||
}
|
||||
}
|
||||
|
||||
// NewDefaultCron returns the default cron implementation for use outside the
|
||||
// scheduling of a job. For example, validating crontab syntax before passing to the
|
||||
// NewJob function.
|
||||
func NewDefaultCron(cronStatementsIncludeSeconds bool) Cron {
|
||||
return &defaultCron{
|
||||
withSeconds: cronStatementsIncludeSeconds,
|
||||
}
|
||||
}
|
||||
|
||||
var _ Cron = (*defaultCron)(nil)
|
||||
|
||||
type defaultCron struct {
|
||||
|
|
|
|||
Loading…
Reference in New Issue