fx.Invoke 执行顺序不确定导致插件路由未注册,改为在 New() 中自注册
This commit is contained in:
parent
9bb2c447ec
commit
7ad62c7488
@ -132,9 +132,6 @@ func NewApp() *fx.App {
|
|||||||
settingsinterfaces.Module,
|
settingsinterfaces.Module,
|
||||||
notificationinterfaces.Module,
|
notificationinterfaces.Module,
|
||||||
exampleinterfaces.Module,
|
exampleinterfaces.Module,
|
||||||
fx.Invoke(func(p *exampleinterfaces.ExamplePlugin) {
|
|
||||||
plugin.Register(p)
|
|
||||||
}),
|
|
||||||
Module,
|
Module,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,10 +17,11 @@ type ExamplePlugin struct {
|
|||||||
handler *Handler
|
handler *Handler
|
||||||
}
|
}
|
||||||
|
|
||||||
// New creates the example plugin.
|
// New creates the example plugin and registers it in the global plugin registry.
|
||||||
// Call this during application bootstrap to register the plugin.
|
|
||||||
func New(handler *Handler) *ExamplePlugin {
|
func New(handler *Handler) *ExamplePlugin {
|
||||||
return &ExamplePlugin{handler: handler}
|
p := &ExamplePlugin{handler: handler}
|
||||||
|
plugin.Register(p)
|
||||||
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ExamplePlugin) Metadata() plugin.Metadata {
|
func (p *ExamplePlugin) Metadata() plugin.Metadata {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user