Documentation
¶
Overview ¶
Package httpapi is the HTTP control surface: POST /dump (optional bearer auth) and GET /healthz (liveness, via the health library). It owns no domain logic; the dump run is driven through a Trigger that both the handler and the optional built-in ticker share, so single-flight lives in exactly one place.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Trigger ¶
type Trigger struct {
// contains filtered or unexported fields
}
Trigger runs one dump under the in-process single-flight guard and the cross-process cycle lock (scheduler.Exclusive). The run context is derived from context.Background(), NOT the HTTP request, so a trigger client that disconnects (a short wget firing a long backup) never cancels the dump; only shutdown cancels it, via the guard. The cycle lock extends single-flight across processes: an exec'd `pg-autodump run` can never dump concurrently with the server, and a rerun request it queues while the server's cycle runs is executed by the server before Run returns (depth-1 coalescing — queued demand is owed a run that starts after it arrived).
func NewTrigger ¶
func NewTrigger(guard *dump.Guard, cycle *scheduler.Exclusive, orch *dump.Orchestrator, log *slog.Logger) *Trigger
NewTrigger builds a Trigger.
func (*Trigger) Run ¶
Run executes one dump run if none is in flight. It returns the per-database results of the caller's own run and ok=true. ok=false (with a nil error) means a run is already in progress: the in-process guard is held, or an exec'd `pg-autodump run` in another process holds the cycle lock. A non-nil error means the cross-process cycle coordination itself failed and nothing ran. Rerun demand queued by exec'd runs during the cycle is consumed before Run returns; the reported results are always the first (the caller's own) run.