go_plugins

package module
v0.0.0-...-cf46ffc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2020 License: GPL-3.0 Imports: 4 Imported by: 0

README

Go    

go-plugins

Plugins management library, it allows to manage plugins and plugins loading.

As library it requires to be imported as following code sample:

import (
    log "github.com/myaccount/myproject/myloggerpackage"
    plugins "github.com/hellgate75/go-plugins"
    "github.com/hellgate75/go-plugins/model"
    "fmt"
)

// Enables the plugins.
func init() {
    var myLogger = log.New()
    plugins.EnablePlugins(model.PluginsConfig{
        "my-root-folder",
        true
    }, myLogger)
}

// Collects and count plugins
func main() {
    pluginsList, err := plugins.GetAllPlugins()
    if err != nil {
        // An error is occurred during plugins load ...
        fmt.Printf("Error occured during plugins load: %v\n", err)
    } else {
        // Plugins are loaded correctly ...
        fmt.Printf("Loaded %v plugins\n", len(pluginsList))
    }
}

You need to implement in the library the method GetProxyStub() it must return an element of type model.ProxyStub. Any plugin can be of different type and model information can be found here:

Main methods are present in this file:

Mandatory method is EnablePlugins.

The logic is easy and components into the plugin are generic. The model.PluginType defines the kind of plugin you are expecting from the input plugin libraries.

Build the project

Build command sample :

go build -buildmode=shared github.com/hellgate75/go-plugins

Test the project

go test -v github.com/hellgate75/go-plugins/...

Enjoy the experience.

License

The library is licensed with LGPL v. 3.0 clauses, with prior authorization of author before any production or commercial use. Use of this library or any extension is prohibited due to high risk of damages due to improper use. No warranty is provided for improper or unauthorized use of this library or any implementation.

Any request can be prompted to the author Fabrizio Torelli at the following email address:

[email protected]

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnablePlugins

func EnablePlugins(config model.PluginsConfig, logger log.Logger)

Enable plugins package and start plugins scan features

func FilterPlugins

func FilterPlugins(filter func(model.Plugin) bool) ([]model.Plugin, error)

Collects and filter (using given filter function) all plugins

func FilterPluginsByType

func FilterPluginsByType(pluginType model.PluginType, filter func(model.Plugin) bool) ([]model.Plugin, error)

Collects and filter (using given filter function) all plugins matching with given plugin type

func GetAllPlugins

func GetAllPlugins() ([]model.Plugin, error)

Collects all available plugins from required folder

func GetPluginProxy

func GetPluginProxy() proxy.Proxy

Collects plugins proxy and eventually load plugins if not already done

func GetPluginsByType

func GetPluginsByType(pluginType model.PluginType) ([]model.Plugin, error)

Collects all plugins matching with given plugin type

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL