Documentation
¶
Overview ¶
Package plugin 插件,用于开发一些需要使用单例模式设计的功能,例如服务发现、消息队列与日志系统等。
- 插件主要以组合方式安装在上下文上,用于扩展上下文的能力。
- 服务与运行时上下文均支持安装插件,注意服务类插件需要支持多线程并发,运行时类插件仅需支持单线程即可。
- 有一类较为特殊的通用类插件,指在服务与运行时上下文均可安装的插件。
Index ¶
- Variables
- func Install[T any](provider PluginProvider, plugin T, name ...string)
- func Uninstall(provider PluginProvider, name string)
- func UnsafePluginBundle(pluginBundle PluginBundle) _UnsafePluginBundledeprecated
- func Using[T any](provider PluginProvider, name string) T
- type PluginBundle
- type PluginInfo
- type PluginProvider
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrPlugin = fmt.Errorf("%w: plugin", exception.ErrCore) // 插件错误
)
Functions ¶
func UnsafePluginBundle
deprecated
func UnsafePluginBundle(pluginBundle PluginBundle) _UnsafePluginBundle
Deprecated: UnsafePluginBundle 访问插件包的内部方法
Types ¶
type PluginBundle ¶
type PluginBundle interface {
PluginProvider
// Install 安装插件,不设置插件名称时,将会使用插件实例名称作为插件名称
Install(pluginFace iface.FaceAny, name ...string)
// Uninstall 卸载插件
Uninstall(name string)
// Get 获取插件
Get(name string) (PluginInfo, bool)
// Range 遍历所有已注册的插件
Range(fun generic.Func1[PluginInfo, bool])
// ReversedRange 反向遍历所有已注册的插件
ReversedRange(fun generic.Func1[PluginInfo, bool])
// contains filtered or unexported methods
}
PluginBundle 插件包
type PluginInfo ¶
type PluginInfo struct {
Name string // 插件名
Face iface.FaceAny // 插件Face
Reflected reflect.Value // 插件反射值
Active bool // 是否激活
}
PluginInfo 插件信息
type PluginProvider ¶
type PluginProvider interface {
// GetPluginBundle 获取插件包
GetPluginBundle() PluginBundle
}
PluginProvider 插件提供者
Click to show internal directories.
Click to hide internal directories.