User workerpool for scanning and hashing
All checks were successful
/ release (push) Successful in 31s

This commit is contained in:
Samuel Lorch 2024-07-11 22:47:26 +02:00
parent f12462250a
commit aeb47c2593
3 changed files with 160 additions and 64 deletions

View file

@ -17,6 +17,7 @@ import (
"github.com/jackc/pgx/v5/pgxpool"
"git.lastassault.de/speatzle/morffix/config"
"git.lastassault.de/speatzle/morffix/workerpool"
)
var conf config.Config
@ -129,8 +130,11 @@ func Start(_conf config.Config, tmplFS embed.FS, staticFS embed.FS, migrationsFS
stopWorkerManagement := make(chan bool, 1)
go manageWorkers(stopWorkerManagement)
scanPool := workerpool.NewWorkerPool(10, 100000)
hashPool := workerpool.NewWorkerPool(5, 100000)
stopScanning := make(chan bool, 1)
go manageScan(stopScanning)
go manageScan(stopScanning, scanPool, hashPool)
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, os.Interrupt)
@ -146,6 +150,10 @@ func Start(_conf config.Config, tmplFS embed.FS, staticFS embed.FS, migrationsFS
stopWorkerManagement <- true
slog.Info("Stopping Scanning...")
stopScanning <- true
slog.Info("Stopping Scanning Pool...")
scanPool.Stop()
slog.Info("Stopping Hashing Pool...")
hashPool.Stop()
slog.Info("Done")
}
}