Documentation
¶
Index ¶
- Variables
- func Start(listenAddr string)
- type App
- func (a *App) Bootstrap() error
- func (a *App) BuildRouter() error
- func (a *App) ConnectMetricStore() error
- func (a *App) ConnectMetricStoreWithRetry() error
- func (a *App) DatabaseMigrationRequired() (DatabaseMigrationRequirement, error)
- func (a *App) InitProviders() error
- func (a *App) InitStores() error
- func (a *App) InstallRequired() (bool, error)
- func (a *App) Run() error
- func (a *App) RunDatabaseMigration(requirement DatabaseMigrationRequirement) (bool, error)
- func (a *App) RunInstallGuide() (bool, error)
- func (a *App) RunMetricStoreRecovery(initialErr error) (bool, error)
- func (a *App) Shutdown() error
- func (a *App) StartBackground() error
- type DatabaseMigrationRequirement
- type Options
- type ReloadManager
Constants ¶
This section is empty.
Variables ¶
var ErrRestartRequested = errors.New("server restart requested")
ErrRestartRequested is returned after a clean shutdown when a configuration change requires the next startup to enter a restricted guide.
Functions ¶
func Start ¶
func Start(listenAddr string)
Start builds an App and runs it through the full startup lifecycle: bootstrap, first-run install guide, database migration, metric store connection/recovery, and finally the normal serving loop. It blocks until the process should exit; a fatal error at any phase logs and exits the process, so a normal return means a clean, voluntary stop (e.g. an incomplete install/recovery guide).
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App owns the server lifecycle. Individual phases live in focused files: bootstrap, metric store, providers, guide, scheduled, and runtime.
func New ¶
New constructs an empty application. Initialization happens in the explicit lifecycle phases called by the command entrypoint.
func (*App) Bootstrap ¶
Bootstrap initializes the primary database and settings. Feature-owned data directories (theme, plugin, ...) are created lazily by their own packages on first use, not pre-created here.
func (*App) BuildRouter ¶
BuildRouter constructs the normal application router and starts reloads.
func (*App) ConnectMetricStore ¶
ConnectMetricStore performs one connection attempt and registers cleanup only after a store has actually opened.
func (*App) ConnectMetricStoreWithRetry ¶
ConnectMetricStoreWithRetry retries the monitoring database connection.
func (*App) DatabaseMigrationRequired ¶
func (a *App) DatabaseMigrationRequired() (DatabaseMigrationRequirement, error)
DatabaseMigrationRequired checks both supported migration inputs before the normal Metric Store connection is initialized. Structure upgrades run first when both inputs exist, then the startup loop detects the legacy tables on its next pass.
func (*App) InitProviders ¶
InitProviders initializes providers needed by the normal application.
func (*App) InitStores ¶
InitStores opens the metric store and starts its report batcher. Historical data migrations are started only through an explicit administrator action.
func (*App) InstallRequired ¶
InstallRequired reports whether the instance still needs the first-run guide.
func (*App) RunDatabaseMigration ¶
func (a *App) RunDatabaseMigration(requirement DatabaseMigrationRequirement) (bool, error)
RunDatabaseMigration serves the same authenticated guide and status model for either migration input while leaving each conversion engine independent.
func (*App) RunInstallGuide ¶
RunInstallGuide exposes only first-run installation APIs. It intentionally does not mount authentication or normal application routes.
func (*App) RunMetricStoreRecovery ¶
RunMetricStoreRecovery keeps login available while exposing only the administrator-protected metric-store recovery API.
func (*App) StartBackground ¶
StartBackground starts scheduled work after all stores are ready.
type DatabaseMigrationRequirement ¶
type DatabaseMigrationRequirement struct {
// contains filtered or unexported fields
}
func (DatabaseMigrationRequirement) Required ¶
func (r DatabaseMigrationRequirement) Required() bool
type Options ¶
type Options struct {
ListenAddr string
}
Options configures the process-wide application runtime.
type ReloadManager ¶
type ReloadManager struct {
// contains filtered or unexported fields
}
ReloadManager 统一收敛所有配置热重载逻辑。
过去 kv.Subscribe 分散在 cmd/server.go、cors.go 等多处,导致:
- 谁监听哪些 key 不清晰;
- 某个 handler panic 会连带影响同一订阅回调里的其它逻辑;
- 关闭时无法统一停止。
ReloadManager 把这些 handler 注册在一处,用单个 kv.Subscribe 分发, 并对每个 handler 做 panic 隔离。
func (*ReloadManager) Register ¶
func (m *ReloadManager) Register(name string, handler func(kv.ConfigEvent))
Register 注册一个命名的热重载处理器。必须在 Start 之前调用。
func (*ReloadManager) Start ¶
func (m *ReloadManager) Start()
Start 向 config 订阅一次,之后每个事件会分发给全部已注册 handler。 重复调用无副作用。