The CronService integrates the gopkg.in/robfig/cron.v2 scheduler into the microkernel.
To add the scheduler simply add it as a dependency to any of your own Service's:
Adding dependency
1package example
2
3import (
4 "github.com/peter-mount/go-kernel"
5 "github.com/peter-mount/go-kernel/cron"
6)
7
8type Example struct {
9 cron *cron.CronService
10}
11
12func (p *Example) Name() string {
13 return "Example"
14}
15
16func (p *Example) Init(k *kernel.Kernel) error {
17 service, err := k.AddService(&cron.CronService{})
18 if err != nil {
19 return err
20 }
21 p.cron = service.(*cron.CronService)
22
23 return nil
24}