ExampleWithCronImplementation

This commit is contained in:
John Roesler 2025-02-25 07:47:40 -06:00
parent 69b4347c4c
commit e1b7d52ebc
No known key found for this signature in database
GPG Key ID: 01B26E6D986E445A
1 changed files with 29 additions and 0 deletions

View File

@ -636,6 +636,35 @@ func ExampleWithContext() {
)
}
var _ gocron.Cron = (*customCron)(nil)
type customCron struct{}
func (c customCron) IsValid(crontab string, location *time.Location, now time.Time) error {
return nil
}
func (c customCron) Next(lastRun time.Time) time.Time {
return time.Now().Add(time.Second)
}
func ExampleWithCronImplementation() {
s, _ := gocron.NewScheduler()
defer func() { _ = s.Shutdown() }()
_, _ = s.NewJob(
gocron.CronJob(
"* * * * *",
false,
),
gocron.NewTask(
func() {},
),
gocron.WithCronImplementation(
&customCron{},
),
)
}
func ExampleWithDisabledDistributedJobLocker() {
// var _ gocron.Locker = (*myLocker)(nil)
//