Save descriptor along with plugin instance.

master
Icedream 2018-04-13 09:47:40 +02:00
parent 50e7125bce
commit ae6b69d40d
Signed by: icedream
GPG Key ID: 1573F6D8EFE4D0CF
1 changed files with 14 additions and 5 deletions

View File

@ -9,12 +9,17 @@ import (
"git.icedream.tech/icedream/uplink/plugins"
)
type registeredPlugin struct {
Instance plugins.PluginInstance
Descriptor plugins.PluginDescriptor
}
type App struct {
Server *httpserver.Server
Authenticator authentication.Authenticator
ChannelManager *channels.ChannelManager
plugins []plugins.PluginInstance
plugins []registeredPlugin
}
func New() *App {
@ -23,7 +28,7 @@ func New() *App {
Authenticator: new(authentication.DummyAuthenticator),
ChannelManager: channels.NewChannelManager(),
plugins: []plugins.PluginInstance{},
plugins: []registeredPlugin{},
}
}
@ -40,14 +45,18 @@ func (app *App) UsePlugin(plugin *plugins.Plugin) {
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() {
for _, plugin := range app.plugins {
plugin.Init()
plugin.Instance.Init()
log.Println("Plugin initialized:", plugin.Descriptor.Name)
}
}