holdalive

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

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.

Types

type Config

type Config struct {
	Enabled  bool
	Interval time.Duration
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL