Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Dispatch ¶
Dispatch executes a handler function asynchronously in a new goroutine. The background context inherits every value from the caller's ctx (logger, Sentry hub, trace IDs, etc.) but the cancellation signal is severed via context.WithoutCancel — the entry-point request will return before the background work completes, and we do not want that to cancel the tail. Handler errors route through errutil.Handle so they land in Sentry alongside the structured log. Pending dispatches are tracked by a package-level WaitGroup so tests can synchronise on completion via Wait().
func DispatchCancelable ¶ added in v0.3.0
DispatchCancelable runs handler in a goroutine that dies with ctx. It is Dispatch minus the context.WithoutCancel: the handler receives the caller's context verbatim, so cancelling it terminates the goroutine.
Use it for a helper goroutine bound to the caller's lifetime — a heartbeat that must stop when the work it guards stops, a ticker owned by one processing flow. Use Dispatch instead for the async tail of a request that has already returned, where the request's cancellation must NOT abort the remaining work. Both are tracked by the same WaitGroup, so Wait() covers either; a handler that never returns therefore blocks Wait() forever, so every loop needs an exit (ctx, a stop channel, or a deadline).
Types ¶
This section is empty.