boot

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: Apache-2.0 Imports: 19 Imported by: 1

README

Boot Package

The boot package is an optional startup shell around Lynx core.

It is responsible for process-facing concerns such as:

  • bootstrap configuration loading
  • signal handling
  • health checking
  • circuit-breaker wiring
  • banner/startup UX
  • Kratos application startup glue

It should not be treated as the heart of plugin orchestration. Core plugin management lives in the root lynx package and plugins/UnifiedRuntime.

Current Boundary

boot is now intentionally less intrusive than before:

  • importing boot no longer calls flag.Parse()
  • importing boot no longer registers -conf eagerly
  • host processes may call RegisterBootstrapFlags(...) before parsing flags
  • Run() / LoadBootstrapConfig() still lazily register -conf for compatibility
  • configuration path resolution happens during explicit bootstrap loading
  • LYNX_CONFIG_PATH remains the default environment-based override

This keeps host applications in control of command-line parsing order while preserving the old shell-facing entrypoint shape.

Main Files

  • application.go
    • Application lifecycle shell
    • signal handling
    • startup / shutdown sequencing
  • configuration.go
    • bootstrap config loading
    • config validation
    • config cleanup wiring
  • config_manager.go
    • configuration path management

Backward Compatibility

The following compatibility aliases remain:

  • type Boot = Application
  • NewLynxApplication(...) == NewApplication(...)

Usage

app := boot.NewApplication(wireFunc, plugins...)
if err := app.Run(); err != nil {
    log.Fatal(err)
}

If the host process wants to parse flags itself, it can do so before Run(). If it does not, LoadBootstrapConfig() still resolves configuration from the registered -conf value or the default config path.

Documentation

Index

Constants

View Source
const (
	DefaultShutdownTimeout         = 30 * time.Second
	DefaultHealthCheckInterval     = 30 * time.Second
	DefaultCircuitBreakerThreshold = 5
	DefaultCircuitBreakerTimeout   = 60 * time.Second
)

Default configuration constants

Variables

This section is empty.

Functions

func RegisterBootstrapFlags added in v1.6.0

func RegisterBootstrapFlags(fs *flag.FlagSet)

RegisterBootstrapFlags registers boot compatibility flags on the provided flag set. Host processes that parse flags before calling Run should invoke this explicitly. The registration is idempotent for the process-wide default FlagSet.

Types

type Application added in v1.2.3

type Application struct {
	// contains filtered or unexported fields
}

Application is an optional bootstrap shell around Lynx core. It owns process-level concerns such as signal handling, startup sequencing, and Kratos integration. It should not be treated as part of the plugin orchestration core itself.

func NewApplication added in v1.2.3

func NewApplication(wire wireApp, plugins ...plugins.Plugin) *Application

NewApplication creates a bootstrap shell around the given wire function and optional plugins. It returns nil if wire is nil. By default the created app is published as the process-wide default; see SetPublishDefaultApp to opt out.

func (*Application) GetHost added in v1.2.3

func (app *Application) GetHost() string

GetHost returns lynx.application.host, or "localhost" if unset.

func (*Application) GetName added in v1.2.3

func (app *Application) GetName() string

GetName returns lynx.application.name, or "lynx" if unset.

func (*Application) GetVersion added in v1.2.3

func (app *Application) GetVersion() string

GetVersion returns lynx.application.version, or "unknown" if unset.

func (*Application) LoadBootstrapConfig added in v1.2.3

func (app *Application) LoadBootstrapConfig() error

LoadBootstrapConfig loads, validates, and stores the local bootstrap config. The path is resolved (in order) from the instance path, the config manager, the -conf flag, then the manager's default. It also registers the cleanup that closes the config on shutdown.

func (*Application) Run added in v1.2.3

func (app *Application) Run() error

Run loads configuration, starts the Lynx core and all plugins, runs the Kratos app, and blocks until shutdown. It installs signal handling and always performs graceful shutdown (and panic recovery) before returning.

func (*Application) SetConfigPath added in v1.6.0

func (app *Application) SetConfigPath(path string) *Application

SetConfigPath binds a bootstrap config path to this Application instance. Instance-scoped paths take precedence over process-wide config manager state.

func (*Application) SetPublishDefaultApp added in v1.6.0

func (app *Application) SetPublishDefaultApp(enabled bool) *Application

SetPublishDefaultApp controls whether Run publishes the created app as the process-wide default Lynx application instance.

type ConfigManager added in v1.2.3

type ConfigManager struct {
	// contains filtered or unexported fields
}

ConfigManager manages application configuration paths

func GetConfigManager added in v1.2.3

func GetConfigManager() *ConfigManager

GetConfigManager returns singleton configuration manager instance

func (*ConfigManager) GetConfigPath added in v1.2.3

func (cm *ConfigManager) GetConfigPath() string

GetConfigPath gets configuration path

func (*ConfigManager) GetDefaultConfigPath added in v1.2.3

func (cm *ConfigManager) GetDefaultConfigPath() string

GetDefaultConfigPath returns LYNX_CONFIG_PATH if set, otherwise "./configs".

func (*ConfigManager) IsConfigPathSet added in v1.2.3

func (cm *ConfigManager) IsConfigPathSet() bool

IsConfigPathSet checks if configuration path is set

func (*ConfigManager) SetConfigPath added in v1.2.3

func (cm *ConfigManager) SetConfigPath(path string)

SetConfigPath sets configuration path

type HealthChecker added in v1.2.3

type HealthChecker struct {
	// contains filtered or unexported fields
}

HealthChecker provides application health monitoring

func (*HealthChecker) IsHealthy added in v1.2.3

func (hc *HealthChecker) IsHealthy() bool

IsHealthy returns the current health status

func (*HealthChecker) Run added in v1.2.3

func (hc *HealthChecker) Run()

Run starts the health checker

func (*HealthChecker) Stop added in v1.2.3

func (hc *HealthChecker) Stop()

Stop stops the health checker

Jump to

Keyboard shortcuts

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