1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-09-15 18:57:04 +00:00

Add feature to refresh all feeds from the user interface

This commit is contained in:
Frédéric Guillot 2017-11-21 22:36:00 -08:00
parent 480b0d94e2
commit 855fb06bc9
19 changed files with 104 additions and 55 deletions

View file

@ -5,20 +5,24 @@
package scheduler
import (
"github.com/miniflux/miniflux2/storage"
"log"
"time"
"github.com/miniflux/miniflux2/storage"
)
// NewScheduler starts a new scheduler to push jobs to a pool of workers.
// NewScheduler starts a new scheduler that push jobs to a pool of workers.
func NewScheduler(store *storage.Storage, workerPool *WorkerPool, frequency, batchSize int) {
c := time.Tick(time.Duration(frequency) * time.Minute)
for now := range c {
jobs := store.GetJobs(batchSize)
log.Printf("[Scheduler:%v] => Pushing %d jobs\n", now, len(jobs))
for _, job := range jobs {
workerPool.Push(job)
go func() {
c := time.Tick(time.Duration(frequency) * time.Minute)
for now := range c {
jobs, err := store.NewBatch(batchSize)
if err != nil {
log.Println("[Scheduler]", err)
} else {
log.Printf("[Scheduler:%v] => Pushing %d jobs\n", now, len(jobs))
workerPool.Push(jobs)
}
}
}
}()
}