fix: 插件自注册 — 在构造函数中注册到全局 Registry
Some checks failed
CI / Build & Test (push) Failing after 31s

fx.Invoke 执行顺序不确定导致插件路由未注册,改为在 New() 中自注册
This commit is contained in:
MengStack Dev 2026-10-03 02:09:30 +08:00
parent 9bb2c447ec
commit 7ad62c7488
2 changed files with 4 additions and 6 deletions

View File

@ -132,9 +132,6 @@ func NewApp() *fx.App {
settingsinterfaces.Module,
notificationinterfaces.Module,
exampleinterfaces.Module,
fx.Invoke(func(p *exampleinterfaces.ExamplePlugin) {
plugin.Register(p)
}),
Module,
)
}

View File

@ -17,10 +17,11 @@ type ExamplePlugin struct {
handler *Handler
}
// New creates the example plugin.
// Call this during application bootstrap to register the plugin.
// New creates the example plugin and registers it in the global plugin registry.
func New(handler *Handler) *ExamplePlugin {
return &ExamplePlugin{handler: handler}
p := &ExamplePlugin{handler: handler}
plugin.Register(p)
return p
}
func (p *ExamplePlugin) Metadata() plugin.Metadata {