aboutsummaryrefslogtreecommitdiff
path: root/worker
diff options
context:
space:
mode:
Diffstat (limited to 'worker')
-rw-r--r--worker/worker.go24
1 files changed, 8 insertions, 16 deletions
diff --git a/worker/worker.go b/worker/worker.go
index 06fac36..a8f1518 100644
--- a/worker/worker.go
+++ b/worker/worker.go
@@ -2,9 +2,7 @@ package worker
import (
"context"
- "time"
- "git.sr.ht/~gabrielgio/midr/db"
"git.sr.ht/~gabrielgio/midr/yt"
work "git.sr.ht/~sircmpwn/dowork"
)
@@ -34,6 +32,13 @@ type Job struct {
Status string
}
+func NewWorkder() Worker {
+ return Worker{
+ c: make(chan command, 10),
+ jobs: make(map[uint]string),
+ }
+}
+
func (w *Worker) CanEnqueue(index uint) bool {
v, found := w.jobs[index]
return !found || v == statusNotQueued
@@ -73,21 +78,8 @@ func (w *Worker) startReader() {
}
}
-func (w *Worker) startScheduler(model db.EntryModel) {
- for true {
- entries := model.All()
- for _, e := range entries {
- w.SpawnWorker(e.ID, e.Link, e.OutputFolder)
- }
- time.Sleep(30 * time.Minute)
- }
-}
-
-func (w *Worker) StartWorker(model db.EntryModel) {
- w.c = make(chan command, 10)
- w.jobs = make(map[uint]string)
+func (w *Worker) StartReader() {
go w.startReader()
- go w.startScheduler(model)
}
func (w *Worker) GetJobs() []Job {