Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Wait ¶
func Wait[T any](ctx context.Context, w http.ResponseWriter, cfg Config, fn func(context.Context) (T, error)) (T, error)
Wait runs fn and, while it is pending, optionally emits HTTP 102 Processing informational responses. 1xx responses do not commit the final status, so normal JSON/SSE error contracts remain intact.
Goroutine allowlist justification (audited exception to the "no per-request handler goroutines" rule): emitting 102 Processing keepalives requires the Execute call and the status write to proceed concurrently, and the caller's ctx must propagate into fn. The done channel is buffered (capacity 1) so the spawned goroutine always exits without a receiver, even when Wait returns early via the cancel path. The cancel path drains done so fn's terminal error cannot race a reused response writer, but the drain is bounded by cancelDrainGrace: a fn that ignores ctx cannot block Wait indefinitely — after the grace Wait returns ctx.Err() and the late send is absorbed by the buffered channel.