fx.Invoke 执行顺序不确定导致插件路由未注册,改为在 New() 中自注册
This commit is contained in:
parent
9bb2c447ec
commit
7ad62c7488
@ -132,9 +132,6 @@ func NewApp() *fx.App {
|
||||
settingsinterfaces.Module,
|
||||
notificationinterfaces.Module,
|
||||
exampleinterfaces.Module,
|
||||
fx.Invoke(func(p *exampleinterfaces.ExamplePlugin) {
|
||||
plugin.Register(p)
|
||||
}),
|
||||
Module,
|
||||
)
|
||||
}
|
||||
|
||||
@ -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 {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user