From 2bb74de7ab8894e9754a4853e07ee7c013ff8ede Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20=C5=81ukawski?= Date: Sun, 15 Apr 2018 01:28:21 +0200 Subject: [PATCH] Address last review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Kacper Ɓukawski --- commands/request.go | 1 + plugin/loader/initializer.go | 10 ++++++---- plugin/loader/loader.go | 12 +----------- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/commands/request.go b/commands/request.go index 2ffff5f97513..afa333bb5aaa 100644 --- a/commands/request.go +++ b/commands/request.go @@ -19,6 +19,7 @@ type Context struct { Online bool ConfigRoot string ReqLog *ReqLog + Plugins *loader.PluginLoader config *config.Config diff --git a/plugin/loader/initializer.go b/plugin/loader/initializer.go index 8c87453a887a..7b6e17cd77e0 100644 --- a/plugin/loader/initializer.go +++ b/plugin/loader/initializer.go @@ -8,8 +8,9 @@ import ( ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format" ) -func initialize(plugins []plugin.Plugin) error { - for _, p := range plugins { +//Initialize all loaded plugins +func (loader *PluginLoader) Initialize() error { + for _, p := range loader.plugins { err := p.Init() if err != nil { return err @@ -19,8 +20,9 @@ func initialize(plugins []plugin.Plugin) error { return nil } -func run(plugins []plugin.Plugin) error { - for _, pl := range plugins { +//Run the plugins +func (loader *PluginLoader) Run() error { + for _, pl := range loader.plugins { switch pl := pl.(type) { case plugin.PluginIPLD: err := runIPLDPlugin(pl) diff --git a/plugin/loader/loader.go b/plugin/loader/loader.go index 6ce5737a8865..43b10e358169 100644 --- a/plugin/loader/loader.go +++ b/plugin/loader/loader.go @@ -62,14 +62,4 @@ func NewPluginLoader(pluginDir string) (*PluginLoader, error) { } return loader, nil -} - -// Initialize all the loaded plugins -func (loader *PluginLoader) Initialize() error { - return initialize(loader.plugins) -} - -// Run all the loaded plugins -func (loader *PluginLoader) Run() error { - return run(loader.plugins) -} +} \ No newline at end of file