httpapi

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: GPL-2.0, GPL-3.0 Imports: 11 Imported by: 0

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

func NewServer

func NewServer(d *Deps) *http.Server

NewServer wires the routes and returns a configured *http.Server.

Types

type Deps

type Deps struct {
	Trigger   *Trigger
	Health    health.Signal
	Log       *slog.Logger
	AuthToken string
}

Deps are the wiring NewServer needs.

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

func (t *Trigger) Run() (results []dump.Result, ok bool, err error)

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.

Jump to

Keyboard shortcuts

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