Documentation
¶
Overview ¶
Package concurrency is the only place in the project where a `go` statement may appear.
Background: a panic in a bare goroutine kills the whole process, no matter how carefully the request path is guarded. That defeats the "should essentially never crash" goal (ADR-0016). The architecture test in test/architecture enforces that no `go` statement occurs outside this package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Go ¶
Go runs fn concurrently. A panic does not terminate the process; it is logged and reported instead. component names the location for the metric and the log.
func Recover ¶
Recover is the reusable guard for request handlers and job execution. Usage: defer concurrency.Recover(ctx, "rest.handler")
It has to be the deferred function itself - `defer Recover(...)`, never a call from inside another deferred closure - because recover() only works one frame deep. A caller that needs to do something afterwards (write a 500, finish a span) recovers itself and calls Report.
func Report ¶
Report counts and logs an already recovered panic. It is the half of Recover that a caller needs when the panic is not the end of the story: an HTTP middleware still owes the client a response, and it cannot write one from a frame that Recover has swallowed.
Both paths go through here, so hubtask_panics_recovered_total has exactly one source.
func SetPanicObserver ¶
func SetPanicObserver(o PanicObserver)
SetPanicObserver is set once at startup by the observability layer.
Types ¶
type PanicObserver ¶
PanicObserver is called for every recovered panic. The metric hubtask_panics_recovered_total hangs off this - its target value is permanently 0.