Documentation ¶
Index ¶
- Constants
- Variables
- func CallFunction(any interface{}, funcName string, funcArgs ...interface{}) ([]interface{}, error)
- func CreatePlugin(iDescription common_type.IInstanceDescription) (common_type.IPlugin, common_type.PluginError)
- func NewPluginCaller() *pluginCaller
- type Caller
- type HostHandler
- func (h *HostHandler) AssignPlugin(descriptor *protocol.PluginInstanceDescriptor) (common_type.IPlugin, common_type.IInstanceDescription, common_type.PluginError)
- func (h *HostHandler) GetDescriptor() *protocol.HostDescriptor
- func (h *HostHandler) InitReport()
- func (h *HostHandler) OnAbility(msg *protocol.PlatformMessage)
- func (h *HostHandler) OnConfigChange(msg *protocol.PlatformMessage)
- func (h *HostHandler) OnConnect() common_type.PluginError
- func (h *HostHandler) OnControlMessage(endpoint *connect.EndpointInfo, msg *protocol.PlatformMessage)
- func (h *HostHandler) OnDisconnect() common_type.PluginError
- func (h *HostHandler) OnError(err common_type.PluginError)
- func (h *HostHandler) OnErrorTarget(msg *protocol.PlatformMessage)
- func (h *HostHandler) OnEvent(msg *protocol.PlatformMessage)
- func (h *HostHandler) OnHeartbeat(msg *protocol.PlatformMessage)
- func (h *HostHandler) OnKillPlugin(msg *protocol.PlatformMessage)
- func (h *HostHandler) OnKillSelf(msg *protocol.PlatformMessage)
- func (h *HostHandler) OnLifeCycle(msg *protocol.PlatformMessage)
- func (h *HostHandler) OnMsg(endpoint *connect.EndpointInfo, msg *protocol.PlatformMessage, ...)
- func (h *HostHandler) OnPluginHTTP(msg *protocol.PlatformMessage)
- func (h *HostHandler) OnPluginMessage(endpoint *connect.EndpointInfo, msg *protocol.PlatformMessage)
- func (h *HostHandler) Run() common_type.PluginError
- func (h *HostHandler) Send(sender common_type.IPlugin, msg *protocol.PlatformMessage) (*protocol.PlatformMessage, common_type.PluginError)
- func (h *HostHandler) SendAsync(sender common_type.IPlugin, msg *protocol.PlatformMessage, ...)
- func (h *HostHandler) SendOnly(msg *protocol.PlatformMessage) (err common_type.PluginError)
- type InstancePool
- func (pool *InstancePool) AddMounted(instanceID string, plugin common_type.IPlugin)
- func (pool *InstancePool) AddRunning(target common_type.IInstanceDescription)
- func (pool *InstancePool) DeleteMountedAndRunning(instanceID string)
- func (pool *InstancePool) DeleteRunning(instanceID string)
- func (pool *InstancePool) GetMounted(instanceID string) (common_type.IPlugin, bool)
- func (pool *InstancePool) GetMountedAndRunning(instanceID string) (plugin common_type.IPlugin, pluginDesc common_type.IInstanceDescription, ...)
- func (pool *InstancePool) GetRunning(instanceID string) (common_type.IInstanceDescription, bool)
- func (pool *InstancePool) ListMounted() []common_type.IPlugin
- func (pool *InstancePool) ListRunning() []common_type.IInstanceDescription
Constants ¶
View Source
const (
RetryReconnectSec = 9
)
Variables ¶
View Source
var RetryReconnectInterval = time.Duration(config.Int("host.retry_reconnect_sec", RetryReconnectSec)) * time.Second
Functions ¶
func CallFunction ¶
func CreatePlugin ¶
func CreatePlugin(iDescription common_type.IInstanceDescription) (common_type.IPlugin, common_type.PluginError)
func NewPluginCaller ¶
func NewPluginCaller() *pluginCaller
Types ¶
type Caller ¶
type Caller interface { CallAbility(plugin common_type.IPlugin, req *protocol.StandardAbilityMessage_AbilityRequestMessage) (*protocol.StandardAbilityMessage_AbilityResponseMessage, common_type.PluginError) CallHTTP(plugin common_type.IPlugin, req *protocol.HttpRequestMessage) (*protocol.HttpResponseMessage, common_type.PluginError) }
type HostHandler ¶
type HostHandler struct {
// contains filtered or unexported fields
}
func Default ¶
func Default(isLocal bool) *HostHandler
func New ¶
func New(id, name, addr, lang, hostVersion, minSysVersion, langVersion string, isLocal bool) *HostHandler
func (*HostHandler) AssignPlugin ¶
func (h *HostHandler) AssignPlugin(descriptor *protocol.PluginInstanceDescriptor) ( common_type.IPlugin, common_type.IInstanceDescription, common_type.PluginError)
AssignPlugin 调用插件的核心函数:
IPlugin.Assign(IInstanceDescription, IResources) PluginError
func (*HostHandler) GetDescriptor ¶
func (h *HostHandler) GetDescriptor() *protocol.HostDescriptor
func (*HostHandler) InitReport ¶
func (h *HostHandler) InitReport()
InitReport 向platform报告,启动消息循环,等待control指令与其他消息
func (*HostHandler) OnAbility ¶
func (h *HostHandler) OnAbility(msg *protocol.PlatformMessage)
func (*HostHandler) OnConfigChange ¶
func (h *HostHandler) OnConfigChange(msg *protocol.PlatformMessage)
func (*HostHandler) OnConnect ¶
func (h *HostHandler) OnConnect() common_type.PluginError
func (*HostHandler) OnControlMessage ¶
func (h *HostHandler) OnControlMessage(endpoint *connect.EndpointInfo, msg *protocol.PlatformMessage)
func (*HostHandler) OnDisconnect ¶
func (h *HostHandler) OnDisconnect() common_type.PluginError
func (*HostHandler) OnError ¶
func (h *HostHandler) OnError(err common_type.PluginError)
func (*HostHandler) OnErrorTarget ¶
func (h *HostHandler) OnErrorTarget(msg *protocol.PlatformMessage)
func (*HostHandler) OnEvent ¶
func (h *HostHandler) OnEvent(msg *protocol.PlatformMessage)
func (*HostHandler) OnHeartbeat ¶
func (h *HostHandler) OnHeartbeat(msg *protocol.PlatformMessage)
func (*HostHandler) OnKillPlugin ¶
func (h *HostHandler) OnKillPlugin(msg *protocol.PlatformMessage)
func (*HostHandler) OnKillSelf ¶
func (h *HostHandler) OnKillSelf(msg *protocol.PlatformMessage)
func (*HostHandler) OnLifeCycle ¶
func (h *HostHandler) OnLifeCycle(msg *protocol.PlatformMessage)
func (*HostHandler) OnMsg ¶
func (h *HostHandler) OnMsg(endpoint *connect.EndpointInfo, msg *protocol.PlatformMessage, err common_type.PluginError)
func (*HostHandler) OnPluginHTTP ¶
func (h *HostHandler) OnPluginHTTP(msg *protocol.PlatformMessage)
OnPluginHTTP 插件的路由类型包括: Addition、Replace、Prefix、Suffix、External。 除了External,其他都是注入到主系统接口中。属于内部接口。 比如Prefix: 当用户请求某个主系统接口时,会先流转到插件,等插件处理完再交回主系统处理。 External: 插件自己提供一个HTTP服务。属于外部接口。 上述两种情况使用msg.Plugin.Http.Request.Internal区分,二者在hostHandler的代码实现上只是调用的处理函数不同。 内部接口使用插件自定义函数,外部则固定使用OnExternalHttpRequest函数处理。
func (*HostHandler) OnPluginMessage ¶
func (h *HostHandler) OnPluginMessage(endpoint *connect.EndpointInfo, msg *protocol.PlatformMessage)
func (*HostHandler) Run ¶
func (h *HostHandler) Run() common_type.PluginError
func (*HostHandler) Send ¶
func (h *HostHandler) Send(sender common_type.IPlugin, msg *protocol.PlatformMessage) (*protocol.PlatformMessage, common_type.PluginError)
func (*HostHandler) SendAsync ¶
func (h *HostHandler) SendAsync(sender common_type.IPlugin, msg *protocol.PlatformMessage, callback connect.CallBack)
func (*HostHandler) SendOnly ¶
func (h *HostHandler) SendOnly(msg *protocol.PlatformMessage) (err common_type.PluginError)
type InstancePool ¶
type InstancePool struct {
// contains filtered or unexported fields
}
func (*InstancePool) AddMounted ¶
func (pool *InstancePool) AddMounted(instanceID string, plugin common_type.IPlugin)
func (*InstancePool) AddRunning ¶
func (pool *InstancePool) AddRunning(target common_type.IInstanceDescription)
func (*InstancePool) DeleteMountedAndRunning ¶
func (pool *InstancePool) DeleteMountedAndRunning(instanceID string)
func (*InstancePool) DeleteRunning ¶
func (pool *InstancePool) DeleteRunning(instanceID string)
func (*InstancePool) GetMounted ¶
func (pool *InstancePool) GetMounted(instanceID string) (common_type.IPlugin, bool)
func (*InstancePool) GetMountedAndRunning ¶
func (pool *InstancePool) GetMountedAndRunning(instanceID string) (plugin common_type.IPlugin, pluginDesc common_type.IInstanceDescription, exist bool)
func (*InstancePool) GetRunning ¶
func (pool *InstancePool) GetRunning(instanceID string) (common_type.IInstanceDescription, bool)
func (*InstancePool) ListMounted ¶
func (pool *InstancePool) ListMounted() []common_type.IPlugin
func (*InstancePool) ListRunning ¶
func (pool *InstancePool) ListRunning() []common_type.IInstanceDescription
ListRunning 列出所有运行的插件实例
Click to show internal directories.
Click to hide internal directories.