mirror of
https://github.com/miniflux/v2.git
synced 2025-08-01 17:38:37 +00:00
Add feature to refresh all feeds from the user interface
This commit is contained in:
parent
480b0d94e2
commit
855fb06bc9
19 changed files with 104 additions and 55 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
|
|
@ -14,9 +14,11 @@ type WorkerPool struct {
|
|||
queue chan model.Job
|
||||
}
|
||||
|
||||
// Push send a job on the queue.
|
||||
func (w *WorkerPool) Push(job model.Job) {
|
||||
w.queue <- job
|
||||
// Push send a list of jobs to the queue.
|
||||
func (w *WorkerPool) Push(jobs model.JobList) {
|
||||
for _, job := range jobs {
|
||||
w.queue <- job
|
||||
}
|
||||
}
|
||||
|
||||
// NewWorkerPool creates a pool of background workers.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue