Documentation ¶
Index ¶
- Constants
- Variables
- func ConfigureHostServe(cb ...func(host.TaskHost))
- func IncludeProfiles(profiles ...string)
- func Register(params ...interface{})
- func RegisterOneShutdown(p interface{})
- func RegisterPostProcessor(p ...interface{})
- func RegisterShutdown(p ...interface{})
- func RegisterStartupAction(p ...interface{})
- type Application
- type ApplicationContext
- type BaseApplication
- func (a *BaseApplication) AfterInitialization(configs ...cmap.ConcurrentMap)
- func (a *BaseApplication) Build() Application
- func (a *BaseApplication) BuildConfigurations() (err error)
- func (a *BaseApplication) ConfigurableFactory() factory.ConfigurableFactory
- func (a *BaseApplication) GetInstance(params ...interface{}) (instance interface{})
- func (a *BaseApplication) GetListByBaseInterface(interfaceInstance interface{}) (instanceList []interface{})
- func (a *BaseApplication) GetProperty(name string) (value interface{}, ok bool)
- func (a *BaseApplication) GetServiceProvider() IServiceProvider
- func (a *BaseApplication) Initialize() (err error)
- func (a *BaseApplication) RegistInstance(instance interface{}) error
- func (a *BaseApplication) RegistInstanceAs(instance interface{}, typ interface{}) error
- func (a *BaseApplication) Run()
- func (a *BaseApplication) RunStartup()
- func (a *BaseApplication) SetAddCommandLineProperties(enabled bool) Application
- func (a *BaseApplication) SetInstance(params ...interface{}) (err error)
- func (a *BaseApplication) SetProperty(name string, value ...interface{}) Application
- func (a *BaseApplication) Shutdown()
- func (a *BaseApplication) SystemConfig() *system.Configuration
- type Configuration
- type IServiceProvider
- type IShutdownAction
- type IStartupAction
- type IStartupActionInfo
- type PostProcessor
Constants ¶
const ( Config = system.Config // ProfilesInclude is the property that allow user include profiles at runtime ProfilesInclude = "app.profiles.include" // Version is the property key of app.version Version = "app.version" )
const (
ApplicationContextName = "app.applicationContext"
)
Variables ¶
var ( // Profiles include profiles initially Profiles []string // ErrInvalidObjectType indicates that configuration type is invalid ErrInvalidObjectType = errors.New("[app] invalid Configuration type, one of app.Configuration need to be embedded") )
Functions ¶
func ConfigureHostServe ¶
func IncludeProfiles ¶
func IncludeProfiles(profiles ...string)
IncludeProfiles include specific profiles
func Register ¶
func Register(params ...interface{})
Register register a struct instance or constructor (func), so that it will be injectable.
func RegisterPostProcessor ¶
func RegisterPostProcessor(p ...interface{})
RegisterPostProcessor register post processor
Types ¶
type Application ¶
type Application interface { Initialize() error SetProperty(name string, value ...interface{}) Application GetProperty(name string) (value interface{}, ok bool) SetAddCommandLineProperties(enabled bool) Application Run() ConfigurableFactory() factory.ConfigurableFactory SystemConfig() *system.Configuration //获取serviceProvider GetServiceProvider() IServiceProvider // 运行启动时行为 Build() Application RunStartup() //shutdown Shutdown() }
var (
HostApplication Application
)
type ApplicationContext ¶
type ApplicationContext interface { IServiceProvider GetProperty(name string) (value interface{}, ok bool) }
ApplicationContext is the alias interface of Application
var (
Context ApplicationContext
)
type BaseApplication ¶
type BaseApplication struct { WorkDir string // contains filtered or unexported fields }
BaseApplication is the base application
func (*BaseApplication) AfterInitialization ¶
func (a *BaseApplication) AfterInitialization(configs ...cmap.ConcurrentMap)
初始化完后执行的post行为
func (*BaseApplication) BuildConfigurations ¶
func (a *BaseApplication) BuildConfigurations() (err error)
获取BuildConfigurations对象
func (*BaseApplication) ConfigurableFactory ¶
func (a *BaseApplication) ConfigurableFactory() factory.ConfigurableFactory
func (*BaseApplication) GetInstance ¶
func (a *BaseApplication) GetInstance(params ...interface{}) (instance interface{})
从ioc容器中获取对象实例
func (*BaseApplication) GetListByBaseInterface ¶
func (a *BaseApplication) GetListByBaseInterface(interfaceInstance interface{}) (instanceList []interface{})
func (*BaseApplication) GetProperty ¶
func (a *BaseApplication) GetProperty(name string) (value interface{}, ok bool)
获取应用属性
func (*BaseApplication) GetServiceProvider ¶
func (a *BaseApplication) GetServiceProvider() IServiceProvider
func (*BaseApplication) RegistInstance ¶
func (a *BaseApplication) RegistInstance(instance interface{}) error
func (*BaseApplication) RegistInstanceAs ¶
func (a *BaseApplication) RegistInstanceAs(instance interface{}, typ interface{}) error
注册一个服务 instance 服务实例 typ 要注册的类型实例
func (*BaseApplication) SetAddCommandLineProperties ¶
func (a *BaseApplication) SetAddCommandLineProperties(enabled bool) Application
SetAddCommandLineProperties set add command line properties to be enabled or disabled
func (*BaseApplication) SetInstance ¶
func (a *BaseApplication) SetInstance(params ...interface{}) (err error)
func (*BaseApplication) SetProperty ¶
func (a *BaseApplication) SetProperty(name string, value ...interface{}) Application
SetProperty set application property should be able to set property from source code by SetProperty, it can be override by program argument, e.g. myapp --app.profiles.active=dev
func (*BaseApplication) SystemConfig ¶
func (a *BaseApplication) SystemConfig() *system.Configuration
返回应用系统配置
type IServiceProvider ¶
type IServiceProvider interface { SetInstance(params ...interface{}) (err error) GetInstance(params ...interface{}) (instance interface{}) GetListByBaseInterface(interfaceInstance interface{}) (instanceList []interface{}) //注册一个服务 //instance 服务实例 //typ 要注册的类型实例 RegistInstanceAs(instance interface{}, typ interface{}) error RegistInstance(instance interface{}) error }
type IShutdownAction ¶
type IShutdownAction interface {
Run()
}
用于shutdown处理
func NewShutdownAction ¶
func NewShutdownAction(runFunc func()) IShutdownAction
使用函数创建一个IShutdownAction对象
type IStartupAction ¶
type IStartupAction interface {
Run()
}
用于post处理
func NewStartupAction ¶
func NewStartupAction(runFunc func()) IStartupAction
使用函数创建一个PostProcessor对象
type IStartupActionInfo ¶
type IStartupActionInfo interface { //设置优先级,越小越高,优先级越高的执行在最前面 // SetPriority(priority int32) SetName(name string) IStartupActionInfo //设置最后执行,最后调用的执行在最后 SetLast() IStartupActionInfo }
封装一个IStartupAction对象信息
func RegisterOneStartupAction ¶
func RegisterOneStartupAction(p interface{}) IStartupActionInfo
注册一个startupAction
type PostProcessor ¶
type PostProcessor interface {
AfterInitialization()
}
用于post处理
func NewPostProcessor ¶
func NewPostProcessor(initializeFunc func()) PostProcessor
使用函数创建一个PostProcessor对象