scheduler.go 666 B

123456789101112131415161718192021222324
  1. // Copyright 2017 Frédéric Guillot. All rights reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. package scheduler
  5. import (
  6. "github.com/miniflux/miniflux2/storage"
  7. "log"
  8. "time"
  9. )
  10. // NewScheduler starts a new scheduler to push jobs to a pool of workers.
  11. func NewScheduler(store *storage.Storage, workerPool *WorkerPool, frequency, batchSize int) {
  12. c := time.Tick(time.Duration(frequency) * time.Minute)
  13. for now := range c {
  14. jobs := store.GetJobs(batchSize)
  15. log.Printf("[Scheduler:%v] => Pushing %d jobs\n", now, len(jobs))
  16. for _, job := range jobs {
  17. workerPool.Push(job)
  18. }
  19. }
  20. }