Documentation
¶
Overview ¶
Package stackapi serves the read-only GitOps status surface: GET /stacks (JSON of per-stack status with on-demand drift) and a server-rendered HTML UI at GET / and /ui. It reads from the in-memory status store the sync loop writes and the live Swarm state via port.StackStateReader; it performs no mutations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler serves the read-only GitOps status surface.
func New ¶
func New(store port.StackStatusStore, live port.StackStateReader, logger *slog.Logger, concurrency int) *Handler
New builds the handler. A nil logger falls back to slog.Default. The store is the one the GitOps loop writes; live reads Swarm for on-demand drift. concurrency is the daemon's --gitops-concurrency (0 hides the "concurrency → ≤K parallel" line in the UI summary, e.g. when GitOps is off).
func (*Handler) ServeHTTP ¶
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP routes GET /stacks (JSON), GET / and /ui (HTML); 404 otherwise, 405 for non-GET.
func (*Handler) WithOrphanScan ¶ added in v0.9.0
func (h *Handler) WithOrphanScan(reader port.SwarmRead, stackNames []string, recorder port.Recorder) *Handler
WithOrphanScan enables the orphan-services section: live Swarm services that belong to no configured stack and carry no swarm.autoscaler.* labels. The scan runs on demand per request (like drift), reading the cluster-wide service listing through reader. A nil reader or empty stack names disables it. recorder (optional, nil-safe) publishes the orphan count as the swarm_hpa_orphan_services gauge on every successful scan. Returns the receiver for chaining at the composition root.