Documentation
¶
Index ¶
- Constants
- func Exit(context Context) (int, error)
- func Loop(context Context) error
- func RunAndLoop(config Configuration) (int, error)
- type ComponentFactory
- type ComponentHolder
- type ComponentHolderFilter
- type ComponentInfo
- type ComponentInstance
- type ComponentLoader
- type ComponentLoading
- type ComponentScope
- type Components
- type ConfigBuilder
- type Configuration
- type Context
- type ContextCollections
- type ContextGetter
- type ContextInfo
- type ContextLoader
- type DefineModule
- func (inst *DefineModule) AddDependency(mod Module)
- func (inst *DefineModule) Apply(cb ConfigBuilder) error
- func (inst *DefineModule) GetDependencies() []Module
- func (inst *DefineModule) GetName() string
- func (inst *DefineModule) GetResources() collection.Resources
- func (inst *DefineModule) GetRevision() int
- func (inst *DefineModule) GetVersion() string
- type ExitCodeGenerator
- type FunctionInjectionTarget
- type FunctionInjectionTargetFn
- type Initializer
- type Injection
- type InjectionSource
- type InjectionTarget
- type Injector
- type Looper
- type Module
- type ModuleBuilder
- func (inst *ModuleBuilder) Create() Module
- func (inst *ModuleBuilder) Dependencies(mods []Module) *ModuleBuilder
- func (inst *ModuleBuilder) Dependency(mod Module) *ModuleBuilder
- func (inst *ModuleBuilder) Name(name string) *ModuleBuilder
- func (inst *ModuleBuilder) OnMount(fn OnMountFunc) *ModuleBuilder
- func (inst *ModuleBuilder) Resources(resources collection.Resources) *ModuleBuilder
- func (inst *ModuleBuilder) Revision(revision int) *ModuleBuilder
- func (inst *ModuleBuilder) Version(version string) *ModuleBuilder
- type OnMountFunc
- type Runnable
- type SimpleContext
Constants ¶
const ExitCodeGeneratorClassName = "exit-code-generator"
const LooperClassName = "looper"
Variables ¶
This section is empty.
Functions ¶
func RunAndLoop ¶ added in v0.0.33
func RunAndLoop(config Configuration) (int, error)
依次调用 Run(), Loop(), Exit()
Types ¶
type ComponentFactory ¶
type ComponentFactory interface {
NewInstance() ComponentInstance
}
ComponentFactory 一个组件的工厂
type ComponentHolder ¶
type ComponentHolder interface {
GetInstance() ComponentInstance
IsOriginalName(name string) bool
GetInfo() ComponentInfo
GetPrototype() lang.Object
GetContext() Context
MakeChild(context Context) ComponentHolder
}
ComponentHolder 一个具体的组件的代理
type ComponentHolderFilter ¶
type ComponentHolderFilter func(name string, holder ComponentHolder) bool
type ComponentInfo ¶
type ComponentInfo interface {
GetID() string
GetClass() string
GetAliases() []string
GetClasses() []string
GetScope() ComponentScope
GetFactory() ComponentFactory
GetPrototype() lang.Object
IsTypeOf(typeName string) bool
IsNameOf(alias string) bool
}
ComponentInfo 一个组件的配置
type ComponentInstance ¶
type ComponentInstance interface {
Get() lang.Object
IsLoaded() bool
Inject(context Context) error
Init() error
Destroy() error
}
ComponentInstance 一个具体的组件的实例的引用
type ComponentLoader ¶
type ComponentLoader interface {
OpenLoading(context Context) (ComponentLoading, error)
}
ComponentLoader 用于加载组件的实例
type ComponentLoading ¶ added in v0.0.9
type ComponentLoading interface {
io.Closer
lang.ErrorHandler
Pool() lang.ReleasePool
Context() Context
Load(h ComponentHolder) (lang.Object, error)
LoadAll(h []ComponentHolder) ([]lang.Object, error)
}
ComponentLoading 表示加载组件的会话
type ComponentScope ¶
type ComponentScope uint32
ComponentScope 枚举表示组件的作用域
const ( // ScopeMin 是作用域的最小值 ScopeMin ComponentScope = 0 // 最小 // ScopeSingleton 表示单例模式 ScopeSingleton ComponentScope = 1 // ScopeContext 表示上下文模式 ScopeContext ComponentScope = 2 // ScopePrototype 表示原型模式 ScopePrototype ComponentScope = 3 // ScopeMax 是作用域的最大值 ScopeMax ComponentScope = 4 // 最大 )
type Components ¶
type Components interface {
// ids
GetComponentNameList(includeAliases bool) []string
// getters
GetComponent(selector string) (ComponentHolder, error)
GetComponents(selector string) []ComponentHolder
GetComponentsByFilter(f ComponentHolderFilter) []ComponentHolder
// export & import
Export(map[string]ComponentHolder) map[string]ComponentHolder
Import(map[string]ComponentHolder)
}
Components 接口表示一个组件的集合
type ConfigBuilder ¶
type ConfigBuilder interface {
AddComponent(info ComponentInfo)
SetResources(res collection.Resources)
SetAttribute(name string, value interface{})
SetEnableLoadPropertiesFromArguments(enable bool)
IsEnableLoadPropertiesFromArguments() bool
DefaultProperties() collection.Properties
Create() Configuration
}
ConfigBuilder 表示应用程序配置
type Configuration ¶
type Configuration interface {
GetLoader() ContextLoader
GetComponents() []ComponentInfo
GetResources() collection.Resources
GetAttributes() collection.Attributes
GetEnvironment() collection.Environment
GetDefaultProperties() collection.Properties
IsEnableLoadPropertiesFromArguments() bool
}
Configuration 表示应用程序配置
type Context ¶
type Context interface {
ContextCollections
ContextInfo
// helper
SetErrorHandler(h lang.ErrorHandler)
GetErrorHandler() lang.ErrorHandler
NewChild() Context
GetComponent(selector string) (lang.Object, error)
GetComponentList(selector string) ([]lang.Object, error)
Injector() Injector
ComponentLoader() ComponentLoader
}
Context 表示一个通用的上下文对象
type ContextCollections ¶
type ContextCollections interface {
GetReleasePool() lang.ReleasePool
GetComponents() Components
GetArguments() collection.Arguments
GetAttributes() collection.Attributes
GetEnvironment() collection.Environment
GetProperties() collection.Properties
GetParameters() collection.Parameters
GetResources() collection.Resources
}
type ContextGetter ¶
type ContextGetter interface {
// for property
GetProperty(name string) (string, error)
GetPropertySafely(name string, _default string) string
GetPropertyString(name string, _default string) string
GetPropertyInt(name string, _default int) int
}
ContextGetter 接口向 Context 的使用者提供简易的 getter 方法
type ContextInfo ¶
type ContextLoader ¶
type ContextLoader interface {
Load(config Configuration, args []string) (Context, error)
}
ContextLoader 用于加载进程上下文
type DefineModule ¶ added in v0.0.33
type DefineModule struct {
Name string
Version string
Revision int
Resources collection.Resources
Dependencies []Module
OnMount OnMountFunc
}
DefineModule 定义一个模块
func (*DefineModule) AddDependency ¶ added in v0.0.33
func (inst *DefineModule) AddDependency(mod Module)
AddDependency 添加一个依赖
func (*DefineModule) Apply ¶ added in v0.0.33
func (inst *DefineModule) Apply(cb ConfigBuilder) error
Apply 向 ConfigBuilder 注册本模块中包含的组件,并注入默认配置
func (*DefineModule) GetDependencies ¶ added in v0.0.33
func (inst *DefineModule) GetDependencies() []Module
GetDependencies 返回依赖的其它模块
func (*DefineModule) GetName ¶ added in v0.0.33
func (inst *DefineModule) GetName() string
GetName 取模块名称
func (*DefineModule) GetResources ¶ added in v0.0.33
func (inst *DefineModule) GetResources() collection.Resources
GetResources 取模块的资源
func (*DefineModule) GetRevision ¶ added in v0.0.33
func (inst *DefineModule) GetRevision() int
GetRevision 取模块修订编号
func (*DefineModule) GetVersion ¶ added in v0.0.33
func (inst *DefineModule) GetVersion() string
GetVersion 取模块版本
type ExitCodeGenerator ¶
type ExitCodeGenerator interface {
ExitCode() int
}
type FunctionInjectionTarget ¶ added in v0.0.9
type FunctionInjectionTarget struct {
// contains filtered or unexported fields
}
func (*FunctionInjectionTarget) Close ¶ added in v0.0.9
func (inst *FunctionInjectionTarget) Close() error
func (*FunctionInjectionTarget) Init ¶ added in v0.0.9
func (inst *FunctionInjectionTarget) Init(fn FunctionInjectionTargetFn) InjectionTarget
type FunctionInjectionTargetFn ¶ added in v0.0.9
type Initializer ¶ added in v0.0.33
type Initializer interface {
SetAttribute(name string, value interface{}) Initializer
Use(module Module) Initializer
Run()
}
Initializer 是应用程序的启动器
type Injection ¶
type Injection interface {
io.Closer
lang.ErrorHandler
Context() Context
Pool() lang.ReleasePool
// 类选择器: ".class"
// ID选择器: "#id"
// 属性选择器: "${prop.name}"
// value选择器: "foo"
// context选择器: "context"
Select(selector string) InjectionSource
}
type InjectionSource ¶ added in v0.0.9
type InjectionSource interface {
io.Closer
Count() int
Selector() string
HasMore() bool
Read() (lang.Object, error)
ReadString() (string, error)
ReadInt() (int, error)
ReadInt32() (int32, error)
ReadInt64() (int64, error)
ReadFloat32() (float32, error)
ReadFloat64() (float64, error)
ReadBool() (bool, error)
}
type InjectionTarget ¶ added in v0.0.9
type Module ¶ added in v0.0.33
type Module interface {
GetName() string
GetVersion() string
GetRevision() int
GetResources() collection.Resources
GetDependencies() []Module
Apply(cb ConfigBuilder) error
}
Module 表示一个可导入的模块
type ModuleBuilder ¶ added in v0.0.33
type ModuleBuilder struct {
// contains filtered or unexported fields
}
ModuleBuilder 用于创建Module对象
func (*ModuleBuilder) Create ¶ added in v0.0.33
func (inst *ModuleBuilder) Create() Module
Create 创建模块
func (*ModuleBuilder) Dependencies ¶ added in v0.0.33
func (inst *ModuleBuilder) Dependencies(mods []Module) *ModuleBuilder
Dependencies 添加一组依赖
func (*ModuleBuilder) Dependency ¶ added in v0.0.33
func (inst *ModuleBuilder) Dependency(mod Module) *ModuleBuilder
Dependency 添加一个依赖
func (*ModuleBuilder) Name ¶ added in v0.0.33
func (inst *ModuleBuilder) Name(name string) *ModuleBuilder
Name 设置模块的名称
func (*ModuleBuilder) OnMount ¶ added in v0.0.33
func (inst *ModuleBuilder) OnMount(fn OnMountFunc) *ModuleBuilder
OnMount 设置配置模块的入口函数
func (*ModuleBuilder) Resources ¶ added in v0.0.33
func (inst *ModuleBuilder) Resources(resources collection.Resources) *ModuleBuilder
Resources 设置跟模块绑定的资源
func (*ModuleBuilder) Revision ¶ added in v0.0.33
func (inst *ModuleBuilder) Revision(revision int) *ModuleBuilder
Revision 设置模块的修订编号
func (*ModuleBuilder) Version ¶ added in v0.0.33
func (inst *ModuleBuilder) Version(version string) *ModuleBuilder
Version 设置模块的版本
type OnMountFunc ¶ added in v0.0.33
type OnMountFunc func(cb ConfigBuilder) error
OnMountFunc 是模块挂载函数的签名
type SimpleContext ¶
type SimpleContext interface {
collection.Atts
}