aboutsummaryrefslogtreecommitdiffhomepage
path: root/scheduler
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <fred@miniflux.net>2017-12-16 18:48:17 -0800
committerGravatar Frédéric Guillot <fred@miniflux.net>2017-12-16 18:48:17 -0800
commit18f55d156995371bfb06ca8cd91da5a922d2a937 (patch)
tree83229e4691ba2ea2e1ddd2de8810cd9ac40e7858 /scheduler
parent00257988ef1707a028cd7dd0b1f8f68e6e8fac53 (diff)
Add scheduler to clean old sessions
Diffstat (limited to 'scheduler')
-rw-r--r--scheduler/scheduler.go22
1 files changed, 17 insertions, 5 deletions
diff --git a/scheduler/scheduler.go b/scheduler/scheduler.go
index 3eac0d1..cc3de6a 100644
--- a/scheduler/scheduler.go
+++ b/scheduler/scheduler.go
@@ -11,18 +11,30 @@ import (
"github.com/miniflux/miniflux/storage"
)
-// NewScheduler starts a new scheduler that push jobs to a pool of workers.
-func NewScheduler(store *storage.Storage, workerPool *WorkerPool, frequency, batchSize int) {
+// NewFeedScheduler starts a new scheduler that push jobs to a pool of workers.
+func NewFeedScheduler(store *storage.Storage, workerPool *WorkerPool, frequency, batchSize int) {
go func() {
c := time.Tick(time.Duration(frequency) * time.Minute)
- for now := range c {
+ for _ = range c {
jobs, err := store.NewBatch(batchSize)
if err != nil {
- logger.Error("[Scheduler] %v", err)
+ logger.Error("[FeedScheduler] %v", err)
} else {
- logger.Debug("[Scheduler:%v] => Pushing %d jobs", now, len(jobs))
+ logger.Debug("[FeedScheduler] Pushing %d jobs", len(jobs))
workerPool.Push(jobs)
}
}
}()
}
+
+// NewSessionScheduler starts a new scheduler that clean old sessions.
+func NewSessionScheduler(store *storage.Storage, frequency int) {
+ go func() {
+ c := time.Tick(time.Duration(frequency) * time.Hour)
+ for _ = range c {
+ nbSessions := store.CleanOldSessions()
+ nbUserSessions := store.CleanOldUserSessions()
+ logger.Debug("[SessionScheduler] cleaned %d sessions and %d user sessions", nbSessions, nbUserSessions)
+ }
+ }()
+}