aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/server/main.go25
1 files changed, 13 insertions, 12 deletions
diff --git a/cmd/server/main.go b/cmd/server/main.go
index daf5356..2a93946 100644
--- a/cmd/server/main.go
+++ b/cmd/server/main.go
@@ -7,6 +7,7 @@ import (
"net/http"
"os"
"os/signal"
+ "time"
"github.com/gorilla/mux"
"github.com/sirupsen/logrus"
@@ -122,37 +123,37 @@ func main() {
albumScanner = scanner.NewAlbumScanner(mediaRepository)
)
- // worker
+ // tasks
var (
- serverWorker = worker.NewServerWorker(&http.Server{Handler: r, Addr: "0.0.0.0:8080"})
- fileWorker = worker.NewWorkerFromChanProcessor[string](
+ serverTask = worker.NewServerTask(&http.Server{Handler: r, Addr: "0.0.0.0:8080"})
+ fileTask = worker.NewTaskFromChanProcessor[string](
fileScanner,
scheduler,
logrus.WithField("context", "file scanner"),
)
- exifWorker = worker.NewWorkerFromBatchProcessor[*repository.Media](
+ exifTask = worker.NewTaskFromBatchProcessor[*repository.Media](
exifScanner,
scheduler,
logrus.WithField("context", "exif scanner"),
)
- thumbnailWorker = worker.NewWorkerFromBatchProcessor[*repository.Media](
+ thumbnailTask = worker.NewTaskFromBatchProcessor[*repository.Media](
thumbnailScanner,
scheduler,
logrus.WithField("context", "thumbnail scanner"),
)
- albumWorker = worker.NewWorkerFromSerialProcessor[*repository.Media](
+ albumTask = worker.NewTaskFromSerialProcessor[*repository.Media](
albumScanner,
scheduler,
logrus.WithField("context", "thumbnail scanner"),
)
)
- pool := worker.NewWorkerPool()
- pool.AddWorker("http server", serverWorker)
- pool.AddWorker("exif scanner", exifWorker)
- pool.AddWorker("file scanner", fileWorker)
- pool.AddWorker("thumbnail scanner", thumbnailWorker)
- pool.AddWorker("album scanner", albumWorker)
+ pool := worker.NewTaskPool()
+ pool.AddTask("http server", time.Minute, serverTask)
+ pool.AddTask("exif scanner", 15*time.Minute, exifTask)
+ pool.AddTask("file scanner", 2*time.Hour, fileTask)
+ pool.AddTask("thumbnail scanner", 15*time.Minute, thumbnailTask)
+ pool.AddTask("album scanner", 15*time.Minute, albumTask)
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt)
defer stop()