app

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: AGPL-3.0 Imports: 26 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyCacheRatioOverrides

func ApplyCacheRatioOverrides()

ApplyCacheRatioOverrides pushes the operator-configured cache-ratio fallback overrides from the runtime-settings snapshot into the routing package's runtime. Called at boot after the snapshot is published, 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 CatalogManager added in v0.16.9

func CatalogManager() *catalogsync.Manager

CatalogManager returns the process-global model-catalog manager (nil when the pricing catalog is disabled or failed to initialize). The admin catalog-sources / catalog-sync endpoints and the marketplace hydration use it to read the merged snapshot and drive manual syncs.

func ConfigureProxyUpstream

func ConfigureProxyUpstream(cfg *config.Config) error

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 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 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 RunOauthIdentityBackfill added in v0.13.0

func RunOauthIdentityBackfill()

RunOauthIdentityBackfill runs the one-time OAuth identity column backfill at startup. It is a bounded migration (LIMIT-batched, settings-marker-gated) so the paginated admin list endpoint never pays the per-page scan+update cost that the old in-request backfill imposed.

Safe to call on every boot: the settings marker short-circuits healthy instances, and a partial run (process killed mid-batch) leaves the marker unset and retries on the next boot. Must run after the runtime database is bootstrapped (store.EnsureRuntimeDatabase) so store.GetDB is non-nil.

func ShutdownPricingCatalog added in v0.14.0

func ShutdownPricingCatalog()

ShutdownPricingCatalog stops the catalog sync loop. Registered as an app OnClose hook during server startup; no-op when the catalog was never enabled.

func ShutdownProxyLogBatchWriter added in v0.13.0

func ShutdownProxyLogBatchWriter(ctx context.Context) error

ShutdownProxyLogBatchWriter drains and stops the global proxy_log batch writer. It is intended to be registered as an app OnClose hook during server startup so the writer flushes its final batch before app.cleanup() calls store.CloseDatabase(). Exposed here (rather than having cmd/server import handler/proxy directly) to keep the cmd → app package boundary intact. No-op when the writer was never started (sync mode / PROXY_LOG_ASYNC=false).

func StartBackgroundServices

func StartBackgroundServices()

StartBackgroundServices creates and starts all 18 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

func UpdateBalanceCron(cronExpr string) error

UpdateBalanceCron hot-reloads the running balance-refresh scheduler with a newly persisted cron. It is a no-op before background services have started.

func UpdateBalanceEnabled added in v0.16.19

func UpdateBalanceEnabled(enabled bool) error

UpdateBalanceEnabled hot-toggles the global balance-refresh switch (#1027) on the running scheduler. It is a no-op before background services have started.

func UpdateCheckinEnabled added in v0.16.19

func UpdateCheckinEnabled(enabled bool)

UpdateCheckinEnabled hot-toggles the global check-in switch (#1027) on the running scheduler. 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 UpdateModelSyncCron added in v0.16.16

func UpdateModelSyncCron(cronExpr string) error

UpdateModelSyncCron hot-reloads the running model-sync scheduler with a newly persisted cron. 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 New

func New(cfg *config.Config, router http.Handler) *App

New creates a new App with the given config and router.

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

func (a *App) Shutdown(ctx context.Context) error

Shutdown performs a graceful shutdown of the HTTP server with the given context.

func (*App) Start

func (a *App) Start() error

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

type HealthStatus struct {
	Status   string `json:"status"`
	Database string `json:"database,omitempty"`
}

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.

Jump to

Keyboard shortcuts

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