Save descriptor along with plugin instance.
parent
50e7125bce
commit
ae6b69d40d
|
@ -9,12 +9,17 @@ import (
|
||||||
"git.icedream.tech/icedream/uplink/plugins"
|
"git.icedream.tech/icedream/uplink/plugins"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type registeredPlugin struct {
|
||||||
|
Instance plugins.PluginInstance
|
||||||
|
Descriptor plugins.PluginDescriptor
|
||||||
|
}
|
||||||
|
|
||||||
type App struct {
|
type App struct {
|
||||||
Server *httpserver.Server
|
Server *httpserver.Server
|
||||||
Authenticator authentication.Authenticator
|
Authenticator authentication.Authenticator
|
||||||
ChannelManager *channels.ChannelManager
|
ChannelManager *channels.ChannelManager
|
||||||
|
|
||||||
plugins []plugins.PluginInstance
|
plugins []registeredPlugin
|
||||||
}
|
}
|
||||||
|
|
||||||
func New() *App {
|
func New() *App {
|
||||||
|
@ -23,7 +28,7 @@ func New() *App {
|
||||||
Authenticator: new(authentication.DummyAuthenticator),
|
Authenticator: new(authentication.DummyAuthenticator),
|
||||||
ChannelManager: channels.NewChannelManager(),
|
ChannelManager: channels.NewChannelManager(),
|
||||||
|
|
||||||
plugins: []plugins.PluginInstance{},
|
plugins: []registeredPlugin{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,14 +45,18 @@ func (app *App) UsePlugin(plugin *plugins.Plugin) {
|
||||||
p.SetAuthenticator(app.Authenticator)
|
p.SetAuthenticator(app.Authenticator)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println("Plugin initialized:", plugin.Descriptor.Name)
|
log.Println("Plugin registered:", plugin.Descriptor.Name)
|
||||||
|
|
||||||
app.plugins = append(app.plugins, pluginInstance)
|
app.plugins = append(app.plugins, registeredPlugin{
|
||||||
|
Instance: pluginInstance,
|
||||||
|
Descriptor: plugin.Descriptor,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *App) Init() {
|
func (app *App) Init() {
|
||||||
for _, plugin := range app.plugins {
|
for _, plugin := range app.plugins {
|
||||||
plugin.Init()
|
plugin.Instance.Init()
|
||||||
|
log.Println("Plugin initialized:", plugin.Descriptor.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue