Documentation
¶
Overview ¶
Package bgloop provides panic recovery for long-lived background goroutines.
An unrecovered panic in any goroutine crashes the whole Go process, not just that goroutine. Long-lived background loops (ticker-driven cleanup, queue pollers) must therefore guard each iteration so a transient panic is logged and the loop survives instead of taking the server down.
Use Recover deferred inside the body of a loop iteration:
for {
select {
case <-ctx.Done():
return
case <-ticker.C:
func() {
defer bgloop.Recover("auth.backgroundCleanup")
doWork(ctx)
}()
}
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.