File tree Expand file tree Collapse file tree 1 file changed +17
-7
lines changed Expand file tree Collapse file tree 1 file changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -8,18 +8,28 @@ import (
88 "github.com/robfig/cron/v3"
99)
1010
11- type options struct {
12- Spec []string `json:"spec,omitempty" yaml:"spec"`
11+ type config struct {
12+ Spec []string
1313}
1414
15- func NewReminderOptions () * options {
16- return & options {
17- Spec : []string {"* * * * * *" },
15+ type OptionFunc func (o * config )
16+
17+ func SetSpec (s []string ) OptionFunc {
18+ return func (o * config ) {
19+ o .Spec = s
20+ }
21+ }
22+
23+ func NewReminderCfg (of ... OptionFunc ) * config {
24+ o := new (config )
25+ for _ , optionFunc := range of {
26+ optionFunc (o )
1827 }
28+ return o
1929}
2030
2131type cronServer struct {
22- o * options
32+ o * config
2333 c * cron.Cron
2434}
2535
@@ -32,6 +42,6 @@ func (r *cronServer) Run(stopCh <-chan struct{}, f cron.Job) {
3242 r .c .Stop ()
3343}
3444
35- func NewReminderClient (o * options ) * cronServer {
45+ func NewReminderClient (o * config ) * cronServer {
3646 return & cronServer {c : cron .New (), o : o }
3747}
You can’t perform that action at this time.
0 commit comments