Unverified Commit ad4f02cb authored by Steven Allen's avatar Steven Allen Committed by GitHub

Merge pull request #6576 from ipfs/feat/easier-preload

feat: improve plugin preload logic
parents f455c8ba 09d51774
......@@ -15,6 +15,13 @@ import (
opentracing "github.com/opentracing/opentracing-go"
)
var preloadPlugins []plugin.Plugin
// Preload adds one or more plugins to the preload list. This should _only_ be called during init.
func Preload(plugins ...plugin.Plugin) {
preloadPlugins = append(preloadPlugins, plugins...)
}
var log = logging.Logger("plugin/loader")
var loadPluginsFunc = func(string) ([]plugin.Plugin, error) {
......
package loader
import (
"github.com/ipfs/go-ipfs/plugin"
pluginbadgerds "github.com/ipfs/go-ipfs/plugin/plugins/badgerds"
pluginflatfs "github.com/ipfs/go-ipfs/plugin/plugins/flatfs"
pluginipldgit "github.com/ipfs/go-ipfs/plugin/plugins/git"
......@@ -12,9 +11,9 @@ import (
// This file is being generated as part of plugin build process
// To change it, modify the plugin/loader/preload.sh
var preloadPlugins = []plugin.Plugin{
pluginipldgit.Plugins[0],
pluginbadgerds.Plugins[0],
pluginflatfs.Plugins[0],
pluginlevelds.Plugins[0],
func init() {
Preload(pluginipldgit.Plugins...)
Preload(pluginbadgerds.Plugins...)
Preload(pluginflatfs.Plugins...)
Preload(pluginlevelds.Plugins...)
}
......@@ -10,7 +10,6 @@ cat <<EOL
package loader
import (
"github.com/ipfs/go-ipfs/plugin"
EOL
to_preload | while read -r name path num; do
......@@ -25,12 +24,14 @@ cat <<EOL
// This file is being generated as part of plugin build process
// To change it, modify the plugin/loader/preload.sh
var preloadPlugins = []plugin.Plugin{
func init() {
EOL
to_preload | while read -r name path num; do
echo "plugin$name.Plugins[$num],"
case "$num" in
'*') echo " Preload(plugin$name.Plugins...)" ;; # All plugins
*) echo " Preload(plugin$name.Plugins[$num])" ;; # A specific plugin
esac
done
echo "}"
# this file contains plugins to be preloaded
# empty lines or starting with '#' are ignored
#
# name go-path number of the sub-plugin
# name go-path number of the sub-plugin or *
ipldgit github.com/ipfs/go-ipfs/plugin/plugins/git 0
ipldgit github.com/ipfs/go-ipfs/plugin/plugins/git *
badgerds github.com/ipfs/go-ipfs/plugin/plugins/badgerds 0
flatfs github.com/ipfs/go-ipfs/plugin/plugins/flatfs 0
levelds github.com/ipfs/go-ipfs/plugin/plugins/levelds 0
badgerds github.com/ipfs/go-ipfs/plugin/plugins/badgerds *
flatfs github.com/ipfs/go-ipfs/plugin/plugins/flatfs *
levelds github.com/ipfs/go-ipfs/plugin/plugins/levelds *
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment