app

package
v0.1.63 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 40 Imported by: 0

Documentation

Overview

Package app provides the main application struct for centralized dependency management and lifecycle control of the GoModel server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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

func New(ctx context.Context, cfg Config) (*App, error)

New creates a new App with all dependencies initialized. The caller must call Shutdown to release resources.

func (*App) AuditLogger

func (a *App) AuditLogger() auditlog.LoggerInterface

AuditLogger returns the audit logger interface.

func (*App) RefreshRuntime

func (a *App) RefreshRuntime(ctx context.Context) (admin.RuntimeRefreshReport, error)

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

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

Shutdown gracefully tears down app components in dependency order. Order: 1. Close long-lived streams, cancel the HTTP server context, and wait for it to stop. 2. Provider subsystem close (stops model refresh loop and cache resources). 3. Batch store close. 4. Usage logger close (flushes pending usage records). 5. Audit logger close (flushes pending audit records).

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

func (a *App) Start(ctx context.Context, addr string) error

Start starts the HTTP server on the given address. This is a blocking call that returns when the server stops.

func (*App) StartWithListener

func (a *App) StartWithListener(ctx context.Context, listener net.Listener) error

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
}

Config holds the configuration options for creating an App.

Jump to

Keyboard shortcuts

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