{"id":17305848,"url":"https://github.com/s8sg/goplug","last_synced_at":"2025-12-16T00:12:06.467Z","repository":{"id":57618201,"uuid":"43587372","full_name":"s8sg/goplug","owner":"s8sg","description":"GoPlug:  A Go Library to Create and Manage Plugin with Dynamic Loading","archived":false,"fork":false,"pushed_at":"2016-03-07T03:50:28.000Z","size":410,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-20T02:08:07.792Z","etag":null,"topics":["golang","golang-library","plugins","rest-microservice"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/s8sg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-03T04:07:10.000Z","updated_at":"2023-03-28T15:07:20.000Z","dependencies_parsed_at":"2022-09-15T18:22:19.198Z","dependency_job_id":null,"html_url":"https://github.com/s8sg/goplug","commit_stats":null,"previous_names":["swarvanusg/goplug"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s8sg%2Fgoplug","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s8sg%2Fgoplug/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s8sg%2Fgoplug/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s8sg%2Fgoplug/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/s8sg","download_url":"https://codeload.github.com/s8sg/goplug/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245751806,"owners_count":20666437,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","golang-library","plugins","rest-microservice"],"created_at":"2024-10-15T11:56:54.626Z","updated_at":"2025-12-16T00:12:04.399Z","avatar_url":"https://github.com/s8sg.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GoPlug \n\n![](https://github.com/swarvanusg/goplug/blob/master/doc/goplug_v2.png)\n\nGoPlug is a pure Go Plugin library 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. \n\n[![GoDoc](https://img.shields.io/badge/api-Godoc-blue.svg?style=flat-square)](https://godoc.org/github.com/swarvanusg/goplug)\n\n### Version\n0.1.0\n\n### Usage\n\n#### Step 1 : Get It\nTo get the GoPlug install Go and execute the below command \n```\ngo get github.com/swarvanusg/GoPlug\n```\n\n#### Step 2: Lifecycle\nGoPlug plugin life-cycle is quite simple as it consist only three state. \n1.  **Stopped** : Plugin is not yet started or stopped\n2.  **Discovered/Installed** : Plugin is discover and ready to be started\n3.  **Started/Loaded** : Plugin is started or Loaded for serving request\n\n###### Plugin Registry\nEach 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.\n\nAuto discovery service at plugin registry could be disabled resulting plugin to be discovered at loading time.\n\n###### Plugin\nEach 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\n\nLazy start could be enabled to make plugin loaded by explicit call to Plugin Registry rather than at discovery. \n\n#### Step 3: Use it  \n##### Plugin Conf\n___\nPlugin conf (.pconf) defines the plugin properties. It is created by the Plugins at Plugin startup and loaded by the Application. \n###### Example.pconf\n```json\n    {\n        \"Name\" : \"NameOfPlugin\",\n        \"NameSpace\" : \"NamespaceOfPlugin\",\n        \"Url\" : \"unix://PluginUrl\",\n        \"sock\" : \"unixSockLocation.sock\",\n        \"LazyLoad\" : false,\n    }\n```\n##### Application That Use Plugins\n___\n![](https://github.com/swarvanusg/goplug/blob/master/doc/goplug_app.png)\n\nPlugin 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.\n```go\n    plugRegConf := GoPlug.PluginRegConf{PluginLocation: \"./PluginLoc\", AutoDiscover: true}\n    /* Initialize a Plugin Registry that will search location \"./PluginLoc\" for '.pconf' file */  \n    pluginReg, err := GoPlug.PluginRegInit(plugRegConf)\n```\nLazyload 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.  \n\n```go\n    plugin, err := pluginReg.LoadPlugin(\"name\", \"namespace\")\n```\nEach plugin is identified by the plugin name and namespace\n```go\n    plugin := pluginReg.GetPlugin(\"name\", \"namespace\")\n```\nPlugin can be searched for available methods (registered methods by Plugin implementation)\n```go\n    methodList := plugin.GetMethods()\n```\nMethod could be executed by method name \n```go\n    returnBytes, err := plugin.Execute(methodName, inputBytes)\n```\nCallback could be registered in Apllication to receive notification from plugin\n```go\n    plugin.RegisterCallback(Foo)\n    ...\n    func Foo(data []byte) {\n        // Callback body called on notification from pugin\n    }\n```\nPlugin could be forced to unload or stopped\n```go\n    err := pluginReg.UnloadPlugin(plugin)\n```\n##### Plugin Implementation\n___\n![](https://github.com/swarvanusg/goplug/blob/master/doc/goplug_plugin.png)\n\nPlugin is initialized with the **Location**, **Name**, **Namespace** (optional), **Url** (optional), **LazyStart conf**, **Activator** and **Stopper**. \nThe Plugin location should be same on which Plugin Registry is configured\n```go\n    config := GoPlug.PluginImplConf{\"PluginLoc\", \"Name\", \"Namespace\", \"unix://URL\", false, activate, stop}\n    plugin, err := GoPlug.PluginInit(config)\n    ...\n    func activate(input []byte) []byte {\n        // Called on Activation of the Plugin\n    }\n    func stop(input []byte) []byte {\n        // Called on Deactivation of the Plugin\n    }\n```\nMethod should be registered before starting the plugin\n```go\nplugin.RegisterMethod(Do)\n...\nfunc Do(input []byte) []byte {\n    // Call on execution of \"Do\" from application\n}\n```\nPlugin start makes the plugin available for the discovery service and to be loaded\n```go\nplugin.Start()\n```\nPlugin could notify application using callback. A list of registered callbacks are available at plugins\n```go\n    //get available callback list\n    callbackList := plugin.GetCallbacks()\n    ...\n    err := plugin.Notify(callbackName, inputBytes)\n```\nPlugin 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. \n```go\nplugin.stop()\n```\n[More ...](https://godoc.org/github.com/swarvanusg/GoPlug#pkg-index)\n\n#### Step 4: How It Works\nPlugins runs as a different process that is started by the plugin registry. For IPC in Linux Unix domain socket is used, where in Windows com is used. The communication is based on HTTP request response model. \n\n### Current Status\nGoPlug is unstable and in active development and testing\n\n### Future Scope\nAs 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 implemented in different languages. Which will allow plugins to be written in different languages.  \n\n### More Information\nThis 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. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs8sg%2Fgoplug","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fs8sg%2Fgoplug","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs8sg%2Fgoplug/lists"}