You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

39 lines
505 B

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"
}