plug is a minimal plugin system for go based on the amazing
Hashicorp go-plugin system.
It uses the same basic concept of launching the plugin as a subprocess
using the os/exec package. It then communicates with the plugin process
using IPC and serialized protobufs. Here are a few differences:
The plugin interface will be generated automatically using a new protobuf
code generator called protoc-gen-plug.
Instead of attaching the stdin/stdout streams to the host process it uses
them for communication between the plugin and host.
It uses a custom protocol for communication between the host and plugin,
this is much faster but also has fewer bells and whistles. There are many
limitations that will probably not be addressed.
If you want a system that is battle tested and well-supported, please use
Hashicorp's go-plugin system. If you need something very simple that
Usage
This package uses the new go protobuf implementation google.golang.org/protobuf,
Install protoc-gen-go (from google.golang.org/protobuf) and protoc-gen-plug
to your path
Create a protobuf with your service definitions (See example/example.proto)
Generate both the go and plug code (See example/gen.sh)
Implement a generated plugin interface (See example/kv/main.go)
Use the plugin with the generated Load{Service} function.
Package plug contains a small runtime for communication between the
host and plugin applications. The only function in this package that
should be directly called is the `plug.Run` function which will start
the main loop in each plugin implementation. All other variables,
constants, types, and functions in this package are only exported
so that they can be used with the code that is generated using
`protoc-gen-plug`.