plug

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2020 License: MIT Imports: 0 Imported by: 0

README

go.dev reference Go Report Card

plug

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,

  1. Install protoc-gen-go (from google.golang.org/protobuf) and protoc-gen-plug to your path
  2. Create a protobuf with your service definitions (See example/example.proto)
  3. Generate both the go and plug code (See example/gen.sh)
  4. Implement a generated plugin interface (See example/kv/main.go)
  5. Use the plugin with the generated Load{Service} function.

Documentation

Overview

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`.

Directories

Path Synopsis
cmd
kv
pkg

Jump to

Keyboard shortcuts

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