From 6e84441dab0a2b89869e33d7e89d14189d9b67c0 Mon Sep 17 00:00:00 2001 From: Gabriel Arakaki Giovanini Date: Sat, 1 Jul 2023 17:55:50 +0200 Subject: feat: Add thumbnailer --- cmd/server/main.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'cmd') diff --git a/cmd/server/main.go b/cmd/server/main.go index 702ca6e..1bd445c 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -33,6 +33,7 @@ func main() { dbCon = flag.String("db-con", "main.db", "Database string connection for given database type. Ref: https://gorm.io/docs/connecting_to_the_database.html") logLevel = flag.String("log-level", "error", "Log level: Choose either trace, debug, info, warning, error, fatal or panic") schedulerCount = flag.Uint("scheduler-count", 10, "How many workers are created to process media files") + cachePath = flag.String("cache-path", "", "Folder to store thumbnail image") // TODO: this will later be replaced by user specific root folder root = flag.String("root", "", "root folder for the whole application. All the workers will use it as working directory") @@ -112,8 +113,9 @@ func main() { // processors var ( - fileScanner = worker.NewFileScanner(*root, mediaRepository) - exifScanner = worker.NewEXIFScanner(mediaRepository) + fileScanner = worker.NewFileScanner(*root, mediaRepository) + exifScanner = worker.NewEXIFScanner(mediaRepository) + thumbnailScanner = worker.NewThumbnailScanner(*cachePath, mediaRepository) ) // worker @@ -129,12 +131,18 @@ func main() { scheduler, logrus.WithField("context", "exif scanner"), ) + thumbnailWorker = worker.NewWorkerFromBatchProcessor[*repository.Media]( + thumbnailScanner, + 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) ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt) defer stop() -- cgit v1.2.3