All Projects → smallnest → Glean

smallnest / Glean

Licence: apache-2.0
hotfix for go applications via plugin, supports Linux and MacOS

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Glean

Cp Ddd Framework
A lightweight flexible development framework for complex business architecture with full ecosystem!轻量级业务中台开发框架,中台架构的顶层设计和完整解决方案!
Stars: ✭ 566 (+352.8%)
Mutual labels:  plugin, hot-reload
Objection Unique
Unique validation for Objection.js
Stars: ✭ 42 (-66.4%)
Mutual labels:  plugin, plugins
React Native Make
A collection of everyday React Native CLI tools
Stars: ✭ 606 (+384.8%)
Mutual labels:  plugin, plugins
Small
A small framework to split app into small parts
Stars: ✭ 5,012 (+3909.6%)
Mutual labels:  plugin, hotfix
Xcactionbar
"Alfred for Xcode" plugin
Stars: ✭ 1,217 (+873.6%)
Mutual labels:  plugin, plugins
Goloader
load and run golang code at runtime. (WARNING: this repo has not been maintained for a long time, please take a look at https://github.com/pkujhd/goloader)
Stars: ✭ 564 (+351.2%)
Mutual labels:  plugin, hot-reload
Unitypluginwithwsl
Unity native plugin with WSL (Windows Subsystem for Linux)
Stars: ✭ 39 (-68.8%)
Mutual labels:  plugin, plugins
Hisocket
It is a lightweight client socket solution, you can used it in C# project or Unity3d
Stars: ✭ 275 (+120%)
Mutual labels:  plugin, plugins
Wordpress Plugin Installer
A PHP class for installing and activating WordPress plugins.
Stars: ✭ 69 (-44.8%)
Mutual labels:  plugin, plugins
Base
Base is the foundation for creating modular, unit testable and highly pluggable, server-side node.js applications.
Stars: ✭ 67 (-46.4%)
Mutual labels:  plugin, plugins
Webpack Pwa Manifest
Progressive Web App Manifest Generator for Webpack, with auto icon resizing and fingerprinting support.
Stars: ✭ 447 (+257.6%)
Mutual labels:  plugin, hot-reload
Speed tools
敏捷开发工具包
Stars: ✭ 85 (-32%)
Mutual labels:  plugin, hotfix
Ts3audiobot
Advanced Musicbot for Teamspeak 3
Stars: ✭ 397 (+217.6%)
Mutual labels:  plugin, plugins
Jengine
JEngine是针对Unity开发者设计的开箱即用的框架,封装了强大的功能,小白也能快速上手,轻松制作可以热更新的游戏 | JEngine is a streamlined and easy-to-use framework designed for Unity Programmers which contains powerful features, beginners can start up quickly and making hot update-able games easily
Stars: ✭ 564 (+351.2%)
Mutual labels:  hotfix, hot-reload
Keepass Yet Another Favicon Downloader
Yet Another Favicon Downloader for KeePass 2.x
Stars: ✭ 354 (+183.2%)
Mutual labels:  plugin, plugins
Segment Open
Segment Source Distribution
Stars: ✭ 34 (-72.8%)
Mutual labels:  plugin, plugins
Node Audio
Graph-based audio api for Node.js based on LabSound and JUCE
Stars: ✭ 67 (-46.4%)
Mutual labels:  plugin, plugins
Betterdiscordapp
Better Discord App enhances Discord desktop app with new features.
Stars: ✭ 1,225 (+880%)
Mutual labels:  plugin, plugins
Bitsofbytes
Code and projects from my blog posts.
Stars: ✭ 89 (-28.8%)
Mutual labels:  plugin, plugins
Mattermost Plugin Remind
a mattermost plugin that sets reminders for users and channels.
Stars: ✭ 121 (-3.2%)
Mutual labels:  plugin

Glean

A go plugin framework that can reload variables and functions from plugins automatically.

License GoDoc travis Go Report Card

Installation

go get -u github.com/smallnest/glean

Feature

  • load symbol and you don't worry about errors
  • load/reload exported variables and funtions from plugins
  • watch plugins' changes and reload pointer of variables and function in applications

Notice glean only can reload functions or variables that can be addresses.

Examples

see Examples

Let's look the httpserver example to learn how to use glean.

httpserver

httpserver is a very very simple http server.

A simple http server is just like this:

var FooHandler = func(w http.ResponseWriter, r *http.Request) {
	fmt.Fprint(w, "Hello, world")
}

http.Handle("/foo", fooHandler)

log.Fatal(http.ListenAndServe(":9988", nil))

Our goal is to replace fooHandler with latest code dynamically (hot fix).

var FooHandler = func(w http.ResponseWriter, r *http.Request) {
	fmt.Fprint(w, "Hello, gp")
}

No need to restart this server.

step1: build the two plugin

enter _example/httpserver/plugins/plugin1 and _example/httpserver/plugins/plugin2, and run the build.sh to generate the so file.

Currently plugin supports linux and MacOS.

step2: modify the server implementation

package main

import (
	"log"
	"net/http"

	"github.com/smallnest/glean"
)

func main() {
	g := glean.New("plugin.json")
	err := g.LoadConfig()
	if err != nil {
		panic(err)
	}

	var fooHandler func(w http.ResponseWriter, r *http.Request)

	err = g.ReloadAndWatch("FooHandlerID", &fooHandler)

	if err != nil {
		panic(err)
	}

	http.HandleFunc("/foo", WarpFuncPtr(&fooHandler))

	log.Fatal(http.ListenAndServe(":9988", nil))
}

func WarpFuncPtr(fn *func(w http.ResponseWriter, r *http.Request)) func(w http.ResponseWriter, r *http.Request) {
	return func(w http.ResponseWriter, r *http.Request) {
		(*fn)(w, r)
	}
}

Firstly create the Glean instance and load config from given file. And then use ReloadAndWatch to load fooHandler and begin to watch its changes. At last use WarpFuncPtr to wrap fooHandler as a HandleFunc.

Run go run main.go to start this server, use a browser to visit "http://locakhost:9988/foo" and you will see hello world

Change the config file plugin.json and replace "file": "plugins/plugin1/plugin1.so" with :

"file": "plugins/plugin2/plugin2.so",

Browser the prior location and you will see hello gp.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].