Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
github.com/swarvanusg/goplug
< GoPlug >
--------
\
\
_____ ----------------- _____
| \/ ---- ---- \/ |
\ ==/ / | | \ \== /
\--/ | () | |() | \--/
/ \---/ ___ \---/ \
| _(===)_ |
| (__/--\__) |
| |_||_| |
\ /
GoPlug is a pure Go Plugin libary project that provides flexibility, Loose Coupling and moduler approach of Building Software in/around Go. The goal of the project is to provide a simple, fast and a reliable plugin architecture that is independent of the platform.
[GpPlug GoDoc] (https://godoc.org/github.com/swarvanusg/GoPlug)
0.1.0
To get the GoPlug install Go and execute the below command
go get github.com/swarvanusg/GoPlug
GoPlug plugin lifecycle is quite simple as it consist only three state.
Each of the application creates a Plugin Registry to manage Plugins. Plugin Registry is based on plugin discovery service that provide api to search, load and unload plugin to/from registry.
Auto discovery service at plugin registry could be disabled resulting plugin to be discovered at loading time.
Each plugin makes itself available for the discovery service, and while discovered it is loaded by the application. On a successful loading start() is called and on a successful uploading stop() is called
Lazy start could be enabled to make plugin loaded by explicit call to Plugin Registry rather than at discovery.
Plugin conf (.pconf) defines the plugin properties. It is created by the Plugins at Plugin startup and loaded by the Application.
{
"Name" : "NameOfPlugin",
"NameSpace" : "NamespaceOfPlugin",
"Url" : "unix://PluginUrl",
"sock" : "unixSockLocation.sock",
"LazyLoad" : false,
}
Plugin registry is initialized with the plugin location where it will search for plugin conf (.pconf), along with the Auto Discover setting. If auto discovery is enabled the discover service starts and search for new plugin, while in other case of discovery service not running, plugin gets discovered while loading (via Explicit call to LoadPlugin) if available.
plugRegConf := GoPlug.PluginRegConf{PluginLocation: "./PluginLoc", AutoDiscover: true}
/* Initialize a Plugin Registry that will search location "./PluginLoc" for '.pconf' file */
pluginReg, err := GoPlug.PluginRegInit(plugRegConf)
Lazyload is a feature that prevents auto loading of a plugin when it is discovered. If Plugin is Configured for lazy load plugin should be loaded explicitly when needed by the user.
plugin, err := pluginReg.LoadPlugin("name", "namespace")
Each plugin is identified by the plugin name and namespace
plugin := pluginReg.GetPlugin("name", "namespace")
Plugin can be searched for available methods (registered methods by Plugin implementation)
methodList := plugin.GetMethods()
Method could be executed by method name
returnBytes, err := plugin.Execute(methodName, inputBytes)
Callback could be registered in Apllication to receive notification from plugin
plugin.RegisterCallback(Foo)
...
func Foo(data []byte) {
// Callback body called on notification from pugin
}
Plugin could be forced to unload or stopped
err := pluginReg.UnloadPlugin(plugin)
Plugin is initialized with the Location, Name, Namespace (optional), Url (optional), LazyStart conf, Activator and Stopper. The Plugin location should be same on which Plugin Registry is configured
config := GoPlug.PluginImplConf{"PluginLoc", "Name", "Namespace", "unix://URL", false, activate, stop}
plugin, err := GoPlug.PluginInit(config)
...
func activate(input []byte) []byte {
// Called on Activation of the Plugin
}
func stop(input []byte) []byte {
// Called on Deactivation of the Plugin
}
Method should be registered before starting the plugin
plugin.RegisterMethod(Do)
...
func Do(input []byte) []byte {
// Call on execution of "Do" from application
}
Plugin start makes the plugin available for the discovery service and to be loaded
plugin.Start()
Plugin could notify application using callback. A list of registered callbacks are available at plugins
//get available callback list
callbackList := plugin.GetCallbacks()
...
err := plugin.Notify(callbackName, inputBytes)
Plugin stop makes the plugin to be stopped and unavailable from the Plugin Reg service. It should be done after plugin is unloaded from the Plugin registry.
plugin.stop()
Plugins runs a different process that sould be started explicitly. Unix domain socket is used for IPC where the communication is based on HTTP request response model.
GoPlug is unstable and in active development and testing
As GoPlug Plugin are independent process and the communication is based on Unix socket and Http. Plugin could be developed using any programming language. In future GoPlug Plugin Implementation library should be implementated in different languages.
This is an early release. I’ve been using it for a while and this is working fine. I like this one pretty well, but no guarantees that it won’t change a bit.
For Any more info Contact:
swarvanusg@gmail.com
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.