kit/cron/README.md

594 B

Cron

This package is a fork of github.com/robfig/cron/v3@v3.0.0 which adds support for mocking the time using k8s.io/utils/clock

See LICENSE for the license of the original package.

Using Cron with Mock Clock

import "k8s.io/utils/clock"

clk := clock.RealClock{}
c := cron.New(cron.WithClock(clk))
c.AddFunc("@every 1h", func() {
 fmt.Println("Every hour")
})
c.Start()
clk.Add(1 * time.Hour)