package xserver import ( "context" "github.com/robfig/cron" ) type Cron struct { cr *cron.Cron err error } func NewCron() *Cron { cr := cron.New() return &Cron{ cr: cr, } } func (c *Cron) Register(spec string, fun func()) error { return c.cr.AddFunc(spec, fun) } func (c *Cron) Start() error { if c.err != nil { return c.err } c.cr.Start() return nil } func (c *Cron) Shutdown(ctx context.Context) error { c.cr.Stop() return nil } func (c *Cron) Name() string { return "cron" }