[go: nahoru, domu]

Skip to content

Commit

Permalink
Merge pull request #4772 from ipfs/misc/codeowners
Browse files Browse the repository at this point in the history
misc: create CODEOWNERS file

License: MIT
Signed-off-by: Kacper Łukawski <kacluk98@gmail.com>
  • Loading branch information
whyrusleeping authored and PlayerWithoutName committed Mar 10, 2018
2 parents b002acc + 8785696 commit 9985522
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 20 deletions.
8 changes: 8 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Please see https://help.github.com/articles/about-codeowners/ for more information

# Global owner
* @Kubuxu

# Subsystem specific owners


50 changes: 30 additions & 20 deletions plugin/loader/load.go → plugin/loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,25 @@ var loadPluginsFunc = func(string) ([]plugin.Plugin, error) {
return nil, nil
}

// LoadPlugins loads and initializes plugins.
func LoadPlugins(pluginDir string) ([]plugin.Plugin, error) {
// PluginLoader keeps track of loaded plugins
type PluginLoader struct {
plugins []plugin.Plugin
}

func loadDynamicPlugins(pluginDir string) ([]plugin.Plugin, error) {
_, err := os.Stat(pluginDir)
if os.IsNotExist(err) {
return nil, nil
}
if err != nil {
return nil, err
}

return loadPluginsFunc(pluginDir)
}

// NewPluginLoader creates new plugin loader
func NewPluginLoader(pluginDir string) (*PluginLoader, error) {
plMap := make(map[string]plugin.Plugin)
for _, v := range preloadPlugins {
plMap[v.Name()] = v
Expand All @@ -38,28 +55,21 @@ func LoadPlugins(pluginDir string) ([]plugin.Plugin, error) {
plMap[pl.Name()] = pl
}

pls := make([]plugin.Plugin, 0, len(plMap))
for _, v := range plMap {
pls = append(pls, v)
}
loader := &PluginLoader{plugins: make([]plugin.Plugin, 0, len(plMap))}

err = initialize(pls)
if err != nil {
return nil, err
for _, v := range plMap {
loader.plugins = append(loader.plugins, v)
}

err = run(pls)
return nil, err
return loader, nil
}

func loadDynamicPlugins(pluginDir string) ([]plugin.Plugin, error) {
_, err := os.Stat(pluginDir)
if os.IsNotExist(err) {
return nil, nil
}
if err != nil {
return nil, err
}
// Initialize all the loaded plugins
func (loader *PluginLoader) Initialize() error {
return initialize(loader.plugins)
}

return loadPluginsFunc(pluginDir)
// Run all the loaded plugins
func (loader *PluginLoader) Run() error {
return run(loader.plugins)
}

0 comments on commit 9985522

Please sign in to comment.