feat: tokenization start, waitlist for background task graceful exit
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user