mirror of
https://github.com/MeshCore-Beacon/beacon-server.git
synced 2026-12-06 21:24:08 +00:00
* feat(db): five pgx pools with fixed session settings and Prometheus tracing * feat(guards): per-family observe/enforce guards with client slots, deadlines and a shadow budget * fix(guards): attribute only guard deadlines and classify like the handlers * feat(db): route API statements by sqlc name; class C always unnamed * feat(admin): statement statistics by sqlc name; create pg_stat_statements where allowed * fix(db): skip pg_stat_statements when no schema is creatable * feat(background): index health against post-rebuild baselines, Postgres activity, job and ingest metrics * feat: separate API, ingest and maintenance stores; guards on the public API; metrics listener * fix(db): keep ingest writes waiting, size the ingest pool to the host, tidy * test(db): give the statements probe a query id of its own
33 lines
944 B
Go
33 lines
944 B
Go
// Copyright 2026 Beacon Contributors
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
package main
|
|
|
|
import (
|
|
"log/slog"
|
|
"net/http"
|
|
"time"
|
|
|
|
"github.com/MeshCore-Beacon/beacon-server/internal/metrics"
|
|
)
|
|
|
|
// newHTTPServer bounds how long a client may take to send headers and how long an idle
|
|
// keep-alive connection stays open. There is no read or write timeout: backup downloads and
|
|
// WebSocket connections run for as long as they need.
|
|
func newHTTPServer(addr string, h http.Handler) *http.Server {
|
|
return &http.Server{
|
|
Addr: addr,
|
|
Handler: h,
|
|
ReadHeaderTimeout: 10 * time.Second,
|
|
IdleTimeout: 120 * time.Second,
|
|
ErrorLog: slog.NewLogLogger(slog.Default().With("component", "http").Handler(), slog.LevelError),
|
|
}
|
|
}
|
|
|
|
// metricsMux serves GET /metrics and nothing else.
|
|
func metricsMux() http.Handler {
|
|
mux := http.NewServeMux()
|
|
mux.Handle("GET /metrics", metrics.Handler())
|
|
return mux
|
|
}
|