feat: tokenization start, waitlist for background task graceful exit

This commit is contained in:
2026-04-07 14:29:25 +02:00
parent 6dd51b7d04
commit 120c12a1f1
6 changed files with 35 additions and 23 deletions
+3
View File
@@ -178,8 +178,11 @@ func (app *application) readInt(qs url.Values, key string, defaultValue int, v *
// The background() helper accepts an arbitrary function as a parameter.
func (app *application) background(fn func()) {
app.wg.Add(1)
// Launch a background goroutine.
go func() {
// Use defer to decrement the WaitGroup counter before the goroutine returns.
defer app.wg.Done()
// Recover any panic.
defer func() {
if err := recover(); err != nil {