Start runs a new scheduler that will call getItems() to get the list of items to schedule.
(ctx context.Context, getItems GetItemsFunc, opts Options)
| 47 | |
| 48 | // Start runs a new scheduler that will call getItems() to get the list of items to schedule. |
| 49 | func Start(ctx context.Context, getItems GetItemsFunc, opts Options) *Scheduler { |
| 50 | timeNow := opts.TimeNow |
| 51 | |
| 52 | if timeNow == nil { |
| 53 | timeNow = clock.Now |
| 54 | } |
| 55 | |
| 56 | s := &Scheduler{ |
| 57 | TimeNow: timeNow, |
| 58 | refreshRequested: opts.RefreshChannel, |
| 59 | closed: make(chan struct{}), |
| 60 | getItems: getItems, |
| 61 | Debug: opts.Debug, |
| 62 | } |
| 63 | |
| 64 | s.wg.Go(func() { |
| 65 | s.run(context.WithoutCancel(ctx)) |
| 66 | }) |
| 67 | |
| 68 | return s |
| 69 | } |
| 70 | |
| 71 | const sleepTimeWhenNoUpcomingSnapshots = 8 * time.Hour |
| 72 |