handler

package
v0.0.0-...-f13fc7a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RetryReconnectSec = 9
)

Variables

View Source
var RetryReconnectInterval = time.Duration(config.Int("host.retry_reconnect_sec", RetryReconnectSec)) * time.Second
View Source
var Timeout = time.Duration(config.Int("host.timeout_sec", defaultTimeoutSec)) * time.Second

Functions

func CallFunction

func CallFunction(any interface{}, funcName string, funcArgs ...interface{}) ([]interface{}, error)

func NewPluginCaller

func NewPluginCaller() *pluginCaller

Types

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

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 (*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 (*HostHandler) SendAsync

func (h *HostHandler) SendAsync(sender common_type.IPlugin, msg *protocol.PlatformMessage, callback connect.CallBack)

func (*HostHandler) SendOnly

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 列出所有运行的插件实例

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL