From 69559164e4ec3556a37718c758eb8a89a6212c6c Mon Sep 17 00:00:00 2001 From: Vishnu Bharathi Date: Sat, 4 Mar 2023 12:57:56 +0530 Subject: [PATCH] cleanup: remove unused schedule module --- schedule/schedule.go | 43 ------------------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 schedule/schedule.go diff --git a/schedule/schedule.go b/schedule/schedule.go deleted file mode 100644 index 6636636..0000000 --- a/schedule/schedule.go +++ /dev/null @@ -1,43 +0,0 @@ -package schedule - -import ( - "errors" - "fmt" - - "github.com/mitchellh/mapstructure" - "github.com/robfig/cron/v3" -) - -var ErrUnknownType = errors.New("unknown schedule type") - -var CronScheduler *cron.Cron - -type Schedule struct { - Type string `mapstructure:"type"` - Config map[string]any `mapstructure:"config"` -} - -func (s *Schedule) Register(autoScaleRequest func()) error { - fmt.Println("debug schedule", s) - switch s.Type { - case "cron": - var c CronConfig - err := mapstructure.Decode(s.Config, &c) - if err != nil { - return fmt.Errorf("unable to decode cron config: %s", err) - } - - if CronScheduler == nil { - CronScheduler = cron.New() - } - fmt.Println("debug cron config", c) - _, err = CronScheduler.AddFunc(c.Expression, autoScaleRequest) - return err - default: - return ErrUnknownType - } -} - -type CronConfig struct { - Expression string `mapstrucuture:"expression"` -}