Documentation
¶
Overview ¶
Package app provides the main application struct for centralized dependency management and lifecycle control of the GoModel server.
Index ¶
- func ApplyOutboundTLS(cfg config.HTTPTLSConfig) error
- func ApplyOutboundTLSEarly(ctx context.Context, cfg config.HTTPTLSConfig) error
- type App
- func (a *App) AuditLogger() auditlog.LoggerInterface
- func (a *App) RefreshRuntime(ctx context.Context) (admin.RuntimeRefreshReport, error)
- func (a *App) Router() core.RoutableProvider
- func (a *App) Shutdown(ctx context.Context) error
- func (a *App) Start(ctx context.Context, addr string) error
- func (a *App) StartWithListener(ctx context.Context, listener net.Listener) error
- func (a *App) UsageLogger() usage.LoggerInterface
- type Config
- type ReencryptOptions
- type ReencryptResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyOutboundTLS ¶ added in v0.2.0
func ApplyOutboundTLS(cfg config.HTTPTLSConfig) error
ApplyOutboundTLS installs the http.tls settings as the process-wide trust for the outbound HTTPS clients. New calls it with resolved settings before any provider builds a transport. Installing unchanged settings is a no-op.
func ApplyOutboundTLSEarly ¶ added in v0.2.0
func ApplyOutboundTLSEarly(ctx context.Context, cfg config.HTTPTLSConfig) error
ApplyOutboundTLSEarly installs the http.tls settings before extensions set up and secret references resolve, so a secret store behind a private CA is reachable on first start. The paths may themselves be references: those using the local built-in schemes (${env:...}, ${file:...}) are resolved on a copy, leaving the configuration for ResolveSecrets. When a path needs any other scheme, or a reference cannot be resolved yet, nothing is installed: New applies the resolved settings, and ResolveSecrets reports the error.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App represents the main application with all its dependencies. It provides centralized lifecycle management for all components.
func New ¶
New creates a new App with all dependencies initialized. The caller must call Shutdown to release resources.
Construction runs as an ordered list of phases (see bootstrap.phases). A failing phase unwinds every subsystem registered so far before the error is returned.
func (*App) AuditLogger ¶
func (a *App) AuditLogger() auditlog.LoggerInterface
AuditLogger returns the audit logger interface.
func (*App) RefreshRuntime ¶
RefreshRuntime performs a manual runtime refresh for admin-triggered actions. It refreshes provider/model metadata and DB-backed in-memory snapshots without touching exact or semantic response caches.
func (*App) Router ¶
func (a *App) Router() core.RoutableProvider
Router returns the core.RoutableProvider for request routing.
func (*App) Shutdown ¶
Shutdown gracefully tears down app components in dependency order:
- Close long-lived streams (ownedByPrologue), so they do not hold the HTTP drain open, then cancel the server context and wait for it to stop.
- Close server-owned resources (ownedByServer) now that no request is in flight.
- Close the remaining subsystems in the order given by shutdownOrder.
Shutdown is idempotent and safe for repeated calls; after the first call, subsequent calls are no-ops. It attempts every close step, aggregates failures, and returns a joined error if any step fails.
func (*App) Start ¶
Start starts the HTTP server on the given address. This is a blocking call that returns when the server stops.
func (*App) StartWithListener ¶
StartWithListener starts the HTTP server on a pre-bound listener. This is primarily useful for tests that need to reserve a loopback port before handing control to the server.
func (*App) UsageLogger ¶
func (a *App) UsageLogger() usage.LoggerInterface
UsageLogger returns the usage logger interface.
type Config ¶
type Config struct {
// AppConfig holds the loaded application configuration and raw provider data
// produced by config.Load.
AppConfig *config.LoadResult
// Factory provides the ProviderFactory used to construct provider instances.
Factory *providers.ProviderFactory
// Extensions optionally carries registered gateway extensions (request
// rewriters, middleware, routes). The registry is snapshotted here; later
// registrations have no effect.
Extensions *ext.Registry
// DemoMode exposes a prominent dashboard warning for public demo instances.
// It does not change persistence or security behavior.
DemoMode bool
// ProductName names the running distribution (for example "gomodel-pro")
// and becomes the default OpenTelemetry service.name. Empty means
// "gomodel".
ProductName string
// RequestReload asks the process to replace this generation with one built
// from the configuration as it stands now, the reload SIGHUP triggers. It
// must not block. The app calls it when a referenced secret other than a
// provider API key rotates. Nil leaves such a change to a manual reload.
RequestReload func(reason string)
// Replaces is the serving generation a reload builds this one to replace,
// nil at startup. A provider credential or MCP server it runs whose
// stored secret references no longer resolve fails the build, so the
// serving generation keeps running it instead of the reload dropping it.
Replaces *App
}
Config holds the configuration options for creating an App.
type ReencryptOptions ¶ added in v0.1.100
type ReencryptOptions struct {
// Config is the loaded configuration; its storage section and key
// wrapper select the database and the key-encryption key.
Config *config.LoadResult
// Extensions supplies compiled-in plugins, whose schemas say which
// guardrail config values are secret.
Extensions *ext.Registry
// RotateDataKey creates and activates a new data key first, so the pass
// moves every value to it.
RotateDataKey bool
}
ReencryptOptions configures ReencryptSecrets.
type ReencryptResult ¶ added in v0.1.100
type ReencryptResult struct {
// ActiveKeyID is the data key every secret is now sealed with.
ActiveKeyID string
Reports []encryption.Report
}
ReencryptResult is what ReencryptSecrets did. It never carries values.
func ReencryptSecrets ¶ added in v0.1.100
func ReencryptSecrets(ctx context.Context, opts ReencryptOptions) (ReencryptResult, error)
ReencryptSecrets seals every dashboard-managed secret stored in plaintext and re-seals values under a data key other than the active one. It is idempotent: a second run rewrites nothing.
Source Files
¶
- app.go
- bootstrap.go
- cluster_sync.go
- extension_inference.go
- extension_shared_store.go
- init_admin.go
- init_catalog.go
- init_foundation.go
- init_server.go
- init_workflows.go
- outbound_tls.go
- plugin_decisions.go
- reload_entities.go
- runtime_refresh.go
- secret_rotation.go
- secret_rotation_entities.go
- secrets.go
- subsystems.go
- versioncheck.go