mirror of https://github.com/dapr/kit.git
* Remove deprecated package github.com/benbjohnson/clock Replaced with k8s.io/utils/clock Fixes #50 Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com> * Apply suggestions from code review Signed-off-by: Alessandro (Ale) Segala <43508+ItalyPaleAle@users.noreply.github.com> --------- Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com> Signed-off-by: Alessandro (Ale) Segala <43508+ItalyPaleAle@users.noreply.github.com> |
||
---|---|---|
.. | ||
.gitignore | ||
.travis.yml | ||
LICENSE | ||
README.md | ||
chain.go | ||
chain_test.go | ||
constantdelay.go | ||
constantdelay_test.go | ||
cron.go | ||
cron_test.go | ||
doc.go | ||
logger.go | ||
option.go | ||
option_test.go | ||
parser.go | ||
parser_test.go | ||
spec.go | ||
spec_test.go |
README.md
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)