(task Task, options ...Option)
| 18 | } |
| 19 | |
| 20 | func CreateSchedulerTask(task Task, options ...Option) (*SchedulerTask, error) { |
| 21 | if task == nil { |
| 22 | return nil, errors.New("task cannot be nil") |
| 23 | } |
| 24 | |
| 25 | runnableTask := &SchedulerTask{ |
| 26 | task: task, |
| 27 | startTime: time.Time{}, |
| 28 | location: time.Local, |
| 29 | } |
| 30 | |
| 31 | for _, option := range options { |
| 32 | err := option(runnableTask) |
| 33 | |
| 34 | if err != nil { |
| 35 | return nil, err |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | return runnableTask, nil |
| 40 | } |
| 41 | |
| 42 | func (task *SchedulerTask) GetInitialDelay() time.Duration { |
| 43 | if task.startTime.IsZero() { |
no outgoing calls