Documentation
¶
Index ¶
- func GetPluginCount(typ common.Type) int
- func GetPluginId(typ common.Type, name string) (int32, error)
- func IsPluginRegistered(typ common.Type, name string) bool
- func RegisterConfigurablePlugin(plugin Plugin, cfg config.BaseConfig)
- func RegisterPlugin(plugin Plugin)
- func RegisterPluginInterface(typ common.Type, plugin interface{})
- func RegisterPluginProxy(typ common.Type, proxy PluginProxy)
- type InitContext
- type Manager
- type Plugin
- type PluginBase
- func (b *PluginBase) Destroy() error
- func (b *PluginBase) GetSDKContextID() string
- func (b *PluginBase) ID() int32
- func (b *PluginBase) Init(ctx *InitContext) error
- func (b *PluginBase) IsEnable(cfg config.Configuration) bool
- func (b *PluginBase) Name() string
- func (b *PluginBase) Start() error
- func (b *PluginBase) Type() common.Type
- type PluginProxy
- type Supplier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsPluginRegistered ¶
IsPluginRegistered 检查插件是否已经注册
func RegisterConfigurablePlugin ¶
func RegisterConfigurablePlugin(plugin Plugin, cfg config.BaseConfig)
RegisterConfigurablePlugin 注册插件到全局配置对象,并注册插件配置类型
func RegisterPluginInterface ¶
RegisterPluginInterface 注册插件接口类型
func RegisterPluginProxy ¶
func RegisterPluginProxy(typ common.Type, proxy PluginProxy)
RegisterPluginProxy 注册插件proxy类型
Types ¶
type InitContext ¶
type InitContext struct {
Config config.Configuration
Plugins Supplier
ValueCtx model.ValueContext
ConnManager network.ConnectionManager
PluginIndex int32
SDKContextID string
}
InitContext 用于插件初始化的上下文对象
type Manager ¶
type Manager interface {
Supplier
// InitPlugins 初始化插件列表
InitPlugins(initContext InitContext, types []common.Type, engine model.Engine, delegate func() error) (err error)
// DestroyPlugins 销毁已初始化的插件列表
DestroyPlugins() (err error)
// StartPlugins 执行已经初始化完毕的插件
StartPlugins() error
}
Manager 插件管理器统一接口
type Plugin ¶
type Plugin interface {
// Type 插件类型
Type() common.Type
// ID 插件id
ID() int32
// GetSDKContextID 返回插件所属的sdkContext的uuid
GetSDKContextID() string
// Name 插件名,一个类型下插件名唯一
Name() string
// Init 初始化插件
Init(ctx *InitContext) error
// Start 启动插件,对于需要依赖外部资源,以及启动协程的操作,在Start方法里面做
Start() error
// Destroy 销毁插件,可用于释放资源
Destroy() error
// IsEnable 插件是否启用
IsEnable(cfg config.Configuration) bool
}
Plugin 所有插件的基础接口
type PluginBase ¶
type PluginBase struct {
// contains filtered or unexported fields
}
PluginBase Plugin Base
func (*PluginBase) GetSDKContextID ¶
func (b *PluginBase) GetSDKContextID() string
GetSDKContextID 获取所属sdkContext的uuid
func (*PluginBase) IsEnable ¶
func (b *PluginBase) IsEnable(cfg config.Configuration) bool
IsEnable is enable
type PluginProxy ¶
PluginProxy Plugin的代理
type Supplier ¶
type Supplier interface {
// GetPlugin 获取插件实例
GetPlugin(typ common.Type, name string) (Plugin, error)
// GetPluginById 通过id获取插件实例
GetPluginById(id int32) (Plugin, error)
// GetPluginsByType 获取一个类型的加载了的插件名字
GetPluginsByType(typ common.Type) []string
// GetEventSubscribers 获取插件事件监听器
GetEventSubscribers(event common.PluginEventType) []common.PluginEventHandler
// RegisterEventSubscriber 注册插件事件监听器,必须在Plugin.Init方法中进行,否则会出现并发读写问题
RegisterEventSubscriber(event common.PluginEventType, handler common.PluginEventHandler)
}
Supplier 插件提供者
Click to show internal directories.
Click to hide internal directories.