Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Application ¶
type Application interface {
Version() string
GetBasePath() string
GetBootstrapPath() string
GetConfigPath() string
GetLangPath() string
GetPublicPath() string
GetResourcePath() string
GetStoragePath() string
Environment(...string) (string, bool)
MaintenanceMode() context.Context
IsDownForMaintenance() bool
SetMaintenanceMode(down bool)
// RunMode returns the current shell mode (web/console/unknown).
RunMode() RunMode
// Register a service provider constructor with the application.
Register(provider ...any) error
Provide(function interface{}, opts ...dig.ProvideOption) error
Invoke(function interface{}, opts ...dig.InvokeOption) error
// Boot the application's service providers.
Boot(ctx context.Context) error
// Register a new boot listener.
Booting(callback func(application Application))
// Register a new "booted" listener.
Booted(callback func(application Application))
// Get the current application locale.
GetLocale() string
// Get the registered service provider instances if any exist.
GetProviders(provider interface{}) []interface{}
// Determine if the application has been bootstrapped before.
HasBeenBootstrapped() bool
// LifecycleState returns the current lifecycle state name.
LifecycleState() string
// Set the current application locale.
SetLocale(locale string)
// Register a terminating callback with the application.
Terminating(callback interface{}) Application
// Terminate the application.
Terminate(ctx context.Context) error
}
Application 接口定义
type ApplicationAware ¶ added in v1.1.0
type ApplicationAware interface {
SetApplication(app Application)
}
ApplicationAware 由需要访问 Application 的组件实现。 Application 会在 Register 或 Bootstrap 前通过该接口完成显式注入。
type ConfigValidator ¶ added in v1.1.0
ConfigValidator 可选接口:Provider 可声明启动前配置校验。
type HealthProvider ¶ added in v1.1.0
HealthProvider 可选接口:参与 readiness 聚合。
type LifecycleError ¶ added in v1.1.0
LifecycleError 描述应用生命周期阶段失败。
func (*LifecycleError) Error ¶ added in v1.1.0
func (e *LifecycleError) Error() string
func (*LifecycleError) Unwrap ¶ added in v1.1.0
func (e *LifecycleError) Unwrap() error
type RunMode ¶ added in v1.2.0
type RunMode string
RunMode identifies how the application shell was started.
const ( // RunModeUnknown means Boot was invoked without WebShell/ConsoleShell. RunModeUnknown RunMode = "" // RunModeWeb means the application is serving HTTP traffic. RunModeWeb RunMode = "web" // RunModeConsole means the application is executing Cobra commands. RunModeConsole RunMode = "console" )
type RunnableProvider ¶ added in v1.1.0
RunnableProvider 可选接口:阻塞型服务(如 HTTP Server)实现,支持 context 取消。
Source Files
¶
- application.go
- errors.go
- service_provider.go
Click to show internal directories.
Click to hide internal directories.