aboutsummaryrefslogtreecommitdiff
path: root/cmd/server
diff options
context:
space:
mode:
authorGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-07-01 17:55:50 +0200
committerGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-07-01 17:55:50 +0200
commit6e84441dab0a2b89869e33d7e89d14189d9b67c0 (patch)
treee015839d495bcfc7619f4efd08f97a1ba603fd82 /cmd/server
parent3f0dc691e2248cc21edd2e74a62b8f28ce95559e (diff)
downloadlens-6e84441dab0a2b89869e33d7e89d14189d9b67c0.tar.gz
lens-6e84441dab0a2b89869e33d7e89d14189d9b67c0.tar.bz2
lens-6e84441dab0a2b89869e33d7e89d14189d9b67c0.zip
feat: Add thumbnailer
Diffstat (limited to 'cmd/server')
-rw-r--r--cmd/server/main.go12
1 files changed, 10 insertions, 2 deletions
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()