Skip to content

Commit

Permalink
ExampleWithCronImplementation
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnRoesler committed Feb 25, 2025
1 parent 69b4347 commit e1b7d52
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
//
Expand Down

0 comments on commit e1b7d52

Please sign in to comment.