@@ -10,20 +10,12 @@ import (
1010 smtypes "github.com/flant/shell-operator/pkg/schedule_manager/types"
1111)
1212
13- type ScheduleManager interface {
14- Stop ()
15- Start ()
16- Add (entry smtypes.ScheduleEntry )
17- Remove (entry smtypes.ScheduleEntry )
18- Ch () chan string
19- }
20-
2113type CronEntry struct {
2214 EntryID cron.EntryID
2315 Ids map [string ]bool
2416}
2517
26- type scheduleManager struct {
18+ type ScheduleManager struct {
2719 ctx context.Context
2820 cancel context.CancelFunc
2921 cron * cron.Cron
@@ -33,11 +25,9 @@ type scheduleManager struct {
3325 logger * log.Logger
3426}
3527
36- var _ ScheduleManager = & scheduleManager {}
37-
38- func NewScheduleManager (ctx context.Context , logger * log.Logger ) * scheduleManager {
28+ func NewScheduleManager (ctx context.Context , logger * log.Logger ) * ScheduleManager {
3929 cctx , cancel := context .WithCancel (ctx )
40- sm := & scheduleManager {
30+ sm := & ScheduleManager {
4131 ctx : cctx ,
4232 cancel : cancel ,
4333 ScheduleCh : make (chan string , 1 ),
@@ -49,7 +39,7 @@ func NewScheduleManager(ctx context.Context, logger *log.Logger) *scheduleManage
4939 return sm
5040}
5141
52- func (sm * scheduleManager ) Stop () {
42+ func (sm * ScheduleManager ) Stop () {
5343 if sm .cancel != nil {
5444 sm .cancel ()
5545 }
@@ -58,7 +48,7 @@ func (sm *scheduleManager) Stop() {
5848// Add create entry for crontab and id and start scheduled function.
5949// Crontab string should be validated with cron.Parse
6050// function before pass to Add.
61- func (sm * scheduleManager ) Add (newEntry smtypes.ScheduleEntry ) {
51+ func (sm * ScheduleManager ) Add (newEntry smtypes.ScheduleEntry ) {
6252 logEntry := sm .logger .With ("operator.component" , "scheduleManager" )
6353
6454 cronEntry , hasCronEntry := sm .Entries [newEntry .Crontab ]
@@ -89,7 +79,7 @@ func (sm *scheduleManager) Add(newEntry smtypes.ScheduleEntry) {
8979 }
9080}
9181
92- func (sm * scheduleManager ) Remove (delEntry smtypes.ScheduleEntry ) {
82+ func (sm * ScheduleManager ) Remove (delEntry smtypes.ScheduleEntry ) {
9383 cronEntry , hasCronEntry := sm .Entries [delEntry .Crontab ]
9484
9585 // Nothing to Remove
@@ -115,14 +105,14 @@ func (sm *scheduleManager) Remove(delEntry smtypes.ScheduleEntry) {
115105 }
116106}
117107
118- func (sm * scheduleManager ) Start () {
108+ func (sm * ScheduleManager ) Start () {
119109 sm .cron .Start ()
120110 go func () {
121111 <- sm .ctx .Done ()
122112 sm .cron .Stop ()
123113 }()
124114}
125115
126- func (sm * scheduleManager ) Ch () chan string {
116+ func (sm * ScheduleManager ) Ch () chan string {
127117 return sm .ScheduleCh
128118}
0 commit comments