Documentation
¶
Index ¶
- func ApplyCacheRatioOverrides(cfg *config.Config)
- func ConfigureProxyUpstream(cfg *config.Config) error
- func Health(w http.ResponseWriter, r *http.Request)
- func MetricsHandler(w http.ResponseWriter, r *http.Request)
- func ObserveProxyOutcome(obs shared.ProxyObservation)
- func ObserveProxySuccess(endpoint string, stream bool, latency time.Duration)
- func PrometheusHandler(w http.ResponseWriter, r *http.Request)
- func Ready(w http.ResponseWriter, r *http.Request)
- func RecordDBConnError()
- func RecordProxyError()
- func RecordProxyRequest()
- func RecordRouteRebuildCompleted()
- func RecordStreamEnd()
- func RecordStreamStart()
- func ReloadWebdavBackup() error
- func SetActiveChannels(n int64)
- func SetDBConnections(n int64)
- func SetMetricsObserver(o shared.Observer)
- func StartBackgroundServices()
- func StartDebugServer(port int)
- func StopBackgroundServices()
- func TokenRouteDecisionRuntime() (*routing.TokenRouter, *routing.RouteDecisionService)
- func UpdateBalanceCron(cronExpr string) error
- func UpdateCheckinSchedule(mode, cronExpr string, intervalHours int, windowStart, windowEnd string) error
- func UpdateLogCleanupSettings(cronExpr string, usageEnabled, programEnabled bool, retentionDays int) error
- func WireGlobalModelProbeScheduler()
- func WireModelProbeScheduler(s *scheduler.ModelProbeScheduler)
- type App
- type HealthStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyCacheRatioOverrides ¶
ApplyCacheRatioOverrides pushes the operator-configured cache-ratio fallback overrides from config into the routing package's runtime. Called at boot after LoadRuntimeSettings hydrates cfg, and again from the admin settings handler on save. 0/missing values fall back to the code defaults (routing.SetCacheRatioDefaults ignores non-positive values).
func ConfigureProxyUpstream ¶
ConfigureProxyUpstream wires the /v1 data plane to the runtime database. Without this, proxy handlers can parse requests but cannot select real channels. Also publishes the TokenRouter / RouteDecisionService for admin decision APIs.
func Health ¶
func Health(w http.ResponseWriter, r *http.Request)
Health handles GET /health as a liveness endpoint. It intentionally returns 200 without touching dependencies: orchestrators should use /ready when they need dependency-aware routing decisions.
func MetricsHandler ¶
func MetricsHandler(w http.ResponseWriter, r *http.Request)
MetricsHandler serves a /debug/vars style endpoint returning JSON with goroutine count and memory statistics. Requires admin auth in production (registered under the admin middleware group).
func ObserveProxyOutcome ¶
func ObserveProxyOutcome(obs shared.ProxyObservation)
ObserveProxyOutcome records labeled outcomes, latency histograms, and the optional Observer hook.
func ObserveProxySuccess ¶
ObserveProxySuccess is a convenience for success-path latency observation.
func PrometheusHandler ¶
func PrometheusHandler(w http.ResponseWriter, r *http.Request)
PrometheusHandler serves Prometheus text-format metrics at GET /metrics. Zero external dependencies — emits only the exposition format directly.
func Ready ¶
func Ready(w http.ResponseWriter, r *http.Request)
Ready handles GET /ready as a readiness endpoint. It returns 503 when the database is not initialized or cannot be pinged.
func RecordDBConnError ¶
func RecordDBConnError()
RecordDBConnError increments the DB connection-budget / open error counter. Exposed on the app facade so lower layers (e.g. scheduler) can record without importing handler/shared — resolves package-boundaries §5.11 exception.
func RecordProxyError ¶
func RecordProxyError()
RecordProxyError increments the proxy error counter.
func RecordProxyRequest ¶
func RecordProxyRequest()
RecordProxyRequest increments the proxy request counter.
func RecordRouteRebuildCompleted ¶
func RecordRouteRebuildCompleted()
RecordRouteRebuildCompleted increments successful route rebuild/cache-invalidate counter.
func RecordStreamStart ¶
func RecordStreamStart()
RecordStreamStart increments active SSE stream count.
func ReloadWebdavBackup ¶ added in v0.10.0
func ReloadWebdavBackup() error
ReloadWebdavBackup hot-reloads the running WebDAV backup scheduler after a config save. It is a no-op before background services have started.
func SetActiveChannels ¶
func SetActiveChannels(n int64)
SetActiveChannels sets the active channel gauge.
func SetDBConnections ¶
func SetDBConnections(n int64)
SetDBConnections sets the DB connection gauge.
func SetMetricsObserver ¶
SetMetricsObserver registers an optional OTEL/Langfuse-style export sink (nil = no-op).
func StartBackgroundServices ¶
func StartBackgroundServices()
StartBackgroundServices creates and starts all 16 background schedulers.
func StartDebugServer ¶
func StartDebugServer(port int)
StartDebugServer is a no-op when the "debug" build tag is not set.
func StopBackgroundServices ¶
func StopBackgroundServices()
StopBackgroundServices stops all background schedulers.
func TokenRouteDecisionRuntime ¶
func TokenRouteDecisionRuntime() (*routing.TokenRouter, *routing.RouteDecisionService)
TokenRouteDecisionRuntime returns the TokenRouter and RouteDecisionService published by ConfigureProxyUpstream. Both may be nil when upstream is not wired. Used by router/admin registration without creating an app↔admin import cycle.
func UpdateBalanceCron ¶ added in v0.10.0
UpdateBalanceCron hot-reloads the running balance-refresh scheduler with a newly persisted cron. It is a no-op before background services have started.
func UpdateCheckinSchedule ¶
func UpdateCheckinSchedule(mode, cronExpr string, intervalHours int, windowStart, windowEnd string) error
UpdateCheckinSchedule applies a persisted checkin schedule to the running scheduler. It is a no-op before background services have started. windowStart/windowEnd are HH:mm bounds for E1 window mode (ignored otherwise).
func UpdateLogCleanupSettings ¶ added in v0.10.0
func UpdateLogCleanupSettings(cronExpr string, usageEnabled, programEnabled bool, retentionDays int) error
UpdateLogCleanupSettings hot-reloads the running log-cleanup scheduler. It is a no-op before background services have started.
func WireGlobalModelProbeScheduler ¶
func WireGlobalModelProbeScheduler()
WireGlobalModelProbeScheduler injects deps into the process-global scheduler if one is already registered (admin / recovery paths).
func WireModelProbeScheduler ¶
func WireModelProbeScheduler(s *scheduler.ModelProbeScheduler)
WireModelProbeScheduler injects ChannelHealthProbe + ChannelHealthRecorder into a ModelProbeScheduler using the router from ConfigureProxyUpstream. Safe no-op when the proxy router has not been configured yet.
Types ¶
type App ¶
type App struct {
Config *config.Config
Router http.Handler
Server *http.Server
// contains filtered or unexported fields
}
App is the top-level application struct that holds all runtime components.
func (*App) OnClose ¶
func (a *App) OnClose()
OnClose executes all registered onClose functions in FIFO order.
func (*App) RegisterOnClose ¶
func (a *App) RegisterOnClose(fn func())
RegisterOnClose adds a cleanup function to be called during shutdown, in FIFO order.
func (*App) Shutdown ¶
Shutdown performs a graceful shutdown of the HTTP server with the given context.
func (*App) Start ¶
Start begins listening on the configured host:port and blocks until a shutdown signal (SIGINT/SIGTERM) is received, then performs a graceful shutdown with a 5-second timeout.
func (*App) WireResponsesWebsocketTransport ¶
func (a *App) WireResponsesWebsocketTransport()
WireResponsesWebsocketTransport registers the Responses WebSocket known limitation on a.Server. Safe no-op when Server is nil. Called from Start; tests may call directly after assigning Server.
type HealthStatus ¶
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package observability is a true leaf (stdlib-only) holding cross-cutting counters that lower layers (scheduler) must record without importing handler/shared or app.
|
Package observability is a true leaf (stdlib-only) holding cross-cutting counters that lower layers (scheduler) must record without importing handler/shared or app. |