Documentation
¶
Overview ¶
Package extension 插件系统,用于扩展服务或运行时能力,例如服务发现、消息队列与日志系统等。
- 插件主要以组合方式安装在服务或运行时上下文上,用于扩展服务或运行时能力。
- 服务与运行时上下文均支持安装插件,注意服务上的插件需要支持多线程环境,运行时上的插件仅需支持单线程环境即可。
Index ¶
- Variables
- func BindEventRuntimeAddInStateChanged(auto iAutoEventRuntimeAddInStateChanged, ...) event.Handle
- func BindEventRuntimeInstallAddIn(auto iAutoEventRuntimeInstallAddIn, subscriber EventRuntimeInstallAddIn, ...) event.Handle
- func BindEventRuntimeUninstallAddIn(auto iAutoEventRuntimeUninstallAddIn, subscriber EventRuntimeUninstallAddIn, ...) event.Handle
- func GenAddInId(name string) uint64
- func GenAddInName(addIn any) string
- func GenAddInNameT[T any]() string
- func Lookup[T any](provider AddInProvider, id uint64) (T, bool)
- func Require[T any](provider AddInProvider, id uint64) T
- func Uninstall(provider AddInProvider, name string)
- func UnsafeRuntimeAddInManager(mgr RuntimeAddInManager) _UnsafeRuntimeAddInManagerdeprecated
- func UnsafeRuntimeAddInStatus(status RuntimeAddInStatus) _UnsafeRuntimeAddInStatusdeprecated
- func UnsafeServiceAddInManager(mgr ServiceAddInManager) _UnsafeServiceAddInManagerdeprecated
- func UnsafeServiceAddInStatus(status ServiceAddInStatus) _UnsafeServiceAddInStatusdeprecated
- type AddInManager
- type AddInProvider
- type AddInState
- type AddInStatus
- type EventRuntimeAddInStateChanged
- type EventRuntimeAddInStateChangedHandler
- type EventRuntimeInstallAddIn
- type EventRuntimeInstallAddInHandler
- type EventRuntimeUninstallAddIn
- type EventRuntimeUninstallAddInHandler
- type EventServiceAddInSnapshot
- type EventServiceInstallAddIn
- type EventServiceUninstallAddIn
- type IRuntimeAddInManagerEventTab
- type RuntimeAddInManager
- type RuntimeAddInStatus
- type ServiceAddInManager
- type ServiceAddInStatus
Constants ¶
This section is empty.
Variables ¶
var ( EventRuntimeInstallAddInId = event.DeclareEventIdT[runtimeAddInManagerEventTab](0) EventRuntimeUninstallAddInId = event.DeclareEventIdT[runtimeAddInManagerEventTab](1) EventRuntimeAddInStateChangedId = event.DeclareEventIdT[runtimeAddInManagerEventTab](2) )
var (
ErrExtension = fmt.Errorf("%w: extension", exception.ErrCore) // 插件系统错误
)
Functions ¶
func BindEventRuntimeAddInStateChanged ¶ added in v0.4.25
func BindEventRuntimeAddInStateChanged(auto iAutoEventRuntimeAddInStateChanged, subscriber EventRuntimeAddInStateChanged, priority ...int32) event.Handle
func BindEventRuntimeInstallAddIn ¶ added in v0.4.25
func BindEventRuntimeInstallAddIn(auto iAutoEventRuntimeInstallAddIn, subscriber EventRuntimeInstallAddIn, priority ...int32) event.Handle
func BindEventRuntimeUninstallAddIn ¶ added in v0.4.25
func BindEventRuntimeUninstallAddIn(auto iAutoEventRuntimeUninstallAddIn, subscriber EventRuntimeUninstallAddIn, priority ...int32) event.Handle
func Lookup ¶ added in v0.4.25
func Lookup[T any](provider AddInProvider, id uint64) (T, bool)
Lookup 查找插件
func Require ¶ added in v0.4.25
func Require[T any](provider AddInProvider, id uint64) T
Require 依赖插件
func UnsafeRuntimeAddInManager
deprecated
added in
v0.4.26
func UnsafeRuntimeAddInManager(mgr RuntimeAddInManager) _UnsafeRuntimeAddInManager
Deprecated: UnsafeRuntimeAddInManager 访问运行时插件管理器的内部方法
func UnsafeRuntimeAddInStatus
deprecated
added in
v0.4.25
func UnsafeRuntimeAddInStatus(status RuntimeAddInStatus) _UnsafeRuntimeAddInStatus
Deprecated: UnsafeRuntimeAddInStatus 访问运行时插件状态信息的内部方法
func UnsafeServiceAddInManager
deprecated
added in
v0.4.26
func UnsafeServiceAddInManager(mgr ServiceAddInManager) _UnsafeServiceAddInManager
Deprecated: UnsafeServiceAddInManager 访问服务插件管理器的内部方法
func UnsafeServiceAddInStatus
deprecated
added in
v0.4.25
func UnsafeServiceAddInStatus(status ServiceAddInStatus) _UnsafeServiceAddInStatus
Deprecated: UnsafeServiceAddInStatus 访问服务插件状态信息的内部方法
Types ¶
type AddInManager ¶ added in v0.3.66
type AddInManager interface {
AddInProvider
// Install 安装插件
Install(addInFace iface.FaceAny, name ...string) AddInStatus
// Uninstall 卸载插件
Uninstall(name string)
// GetByName 使用名称查询插件状态信息
GetByName(name string) (AddInStatus, bool)
// GetById 使用Id查询插件状态信息
GetById(id uint64) (AddInStatus, bool)
// List 获取所有插件状态信息
List() []AddInStatus
}
AddInManager 插件管理器
type AddInProvider ¶ added in v0.3.66
type AddInProvider interface {
// AddInManager 获取插件管理器
AddInManager() AddInManager
}
AddInProvider 插件提供者
type AddInState ¶ added in v0.3.66
type AddInState int8
AddInState 插件状态
const ( AddInState_Loaded AddInState = iota // 已加载 AddInState_Running // 运行中 AddInState_Unloaded // 已卸载 )
func (AddInState) String ¶ added in v0.3.66
func (i AddInState) String() string
type AddInStatus ¶ added in v0.3.66
type AddInStatus interface {
fmt.Stringer
// Id 插件Id
Id() uint64
// Name 插件名称
Name() string
// InstanceFace 插件实例
InstanceFace() iface.FaceAny
// Reflected 插件反射值
Reflected() reflect.Value
// State 状态
State() AddInState
}
AddInStatus 插件状态信息
func Install ¶
func Install[T any](provider AddInProvider, addIn T, name ...string) AddInStatus
Install 安装插件
type EventRuntimeAddInStateChanged ¶ added in v0.4.25
type EventRuntimeAddInStateChanged interface {
OnRuntimeAddInStateChanged(status RuntimeAddInStatus, state AddInState)
}
EventRuntimeAddInStateChanged 事件:运行时插件状态改变 +event-gen:export_emit=0 +event-tab-gen:recursion=allow
type EventRuntimeAddInStateChangedHandler ¶ added in v0.4.25
type EventRuntimeAddInStateChangedHandler func(status RuntimeAddInStatus, state AddInState)
func HandleEventRuntimeAddInStateChanged ¶ added in v0.4.25
func HandleEventRuntimeAddInStateChanged(fun func(status RuntimeAddInStatus, state AddInState)) EventRuntimeAddInStateChangedHandler
func (EventRuntimeAddInStateChangedHandler) OnRuntimeAddInStateChanged ¶ added in v0.4.25
func (h EventRuntimeAddInStateChangedHandler) OnRuntimeAddInStateChanged(status RuntimeAddInStatus, state AddInState)
type EventRuntimeInstallAddIn ¶ added in v0.4.25
type EventRuntimeInstallAddIn interface {
OnRuntimeInstallAddIn(status RuntimeAddInStatus)
}
EventRuntimeInstallAddIn 事件:运行时安装插件 +event-gen:export_emit=0 +event-tab-gen:recursion=allow
type EventRuntimeInstallAddInHandler ¶ added in v0.4.25
type EventRuntimeInstallAddInHandler func(status RuntimeAddInStatus)
func HandleEventRuntimeInstallAddIn ¶ added in v0.4.25
func HandleEventRuntimeInstallAddIn(fun func(status RuntimeAddInStatus)) EventRuntimeInstallAddInHandler
func (EventRuntimeInstallAddInHandler) OnRuntimeInstallAddIn ¶ added in v0.4.25
func (h EventRuntimeInstallAddInHandler) OnRuntimeInstallAddIn(status RuntimeAddInStatus)
type EventRuntimeUninstallAddIn ¶ added in v0.4.25
type EventRuntimeUninstallAddIn interface {
OnRuntimeUninstallAddIn(status RuntimeAddInStatus)
}
EventRuntimeUninstallAddIn 事件:运行时卸载插件 +event-gen:export_emit=0 +event-tab-gen:recursion=allow
type EventRuntimeUninstallAddInHandler ¶ added in v0.4.25
type EventRuntimeUninstallAddInHandler func(status RuntimeAddInStatus)
func HandleEventRuntimeUninstallAddIn ¶ added in v0.4.25
func HandleEventRuntimeUninstallAddIn(fun func(status RuntimeAddInStatus)) EventRuntimeUninstallAddInHandler
func (EventRuntimeUninstallAddInHandler) OnRuntimeUninstallAddIn ¶ added in v0.4.25
func (h EventRuntimeUninstallAddInHandler) OnRuntimeUninstallAddIn(status RuntimeAddInStatus)
type EventServiceAddInSnapshot ¶ added in v0.4.25
type EventServiceAddInSnapshot struct {
Statuses []ServiceAddInStatus
}
EventServiceAddInSnapshot 服务插件快照事件
type EventServiceInstallAddIn ¶ added in v0.4.25
type EventServiceInstallAddIn struct {
Status ServiceAddInStatus
}
EventServiceInstallAddIn 服务安装插件事件
type EventServiceUninstallAddIn ¶ added in v0.4.25
type EventServiceUninstallAddIn struct {
Status ServiceAddInStatus
}
EventServiceUninstallAddIn 服务卸载插件事件
type IRuntimeAddInManagerEventTab ¶ added in v0.4.25
type RuntimeAddInManager ¶ added in v0.4.25
type RuntimeAddInManager interface {
AddInManager
IRuntimeAddInManagerEventTab
// contains filtered or unexported methods
}
RuntimeAddInManager 运行时插件管理器
func NewRuntimeAddInManager ¶ added in v0.4.25
func NewRuntimeAddInManager() RuntimeAddInManager
NewRuntimeAddInManager 创建运行时插件管理器
type RuntimeAddInStatus ¶ added in v0.4.25
type RuntimeAddInStatus interface {
AddInStatus
// contains filtered or unexported methods
}
RuntimeAddInStatus 运行时插件状态信息
type ServiceAddInManager ¶ added in v0.4.25
type ServiceAddInManager interface {
AddInManager
// WatchEvent 监听插件事件
WatchEvent(ctx context.Context) <-chan any
// contains filtered or unexported methods
}
ServiceAddInManager 服务插件管理器
func NewServiceAddInManager ¶ added in v0.4.25
func NewServiceAddInManager() ServiceAddInManager
NewServiceAddInManager 创建服务插件管理器
type ServiceAddInStatus ¶ added in v0.4.25
type ServiceAddInStatus interface {
AddInStatus
// WaitState 等待状态完成
WaitState(state AddInState) async.AsyncRet
// contains filtered or unexported methods
}
ServiceAddInStatus 服务插件状态信息
Source Files
¶
- addin_declaration.go
- addinmanager.go
- addinmanager_provider.go
- addinstate.go
- addinstate_string.go
- addinstatus.go
- doc.go
- errors.go
- runtime_addinmanager.go
- runtime_addinmanager_event.gen.go
- runtime_addinmanager_event.go
- runtime_addinmanager_eventtab.gen.go
- runtime_addinstatus.go
- service_addinevent.go
- service_addinmanager.go
- service_addinstatus.go
- unsafe_runtime_addinmanager.go
- unsafe_runtime_addinstatus.go
- unsafe_service_addinmanager.go
- unsafe_service_addinstatus.go