Lists of producer plugins for JR. Currently the following plugins are included:
awsdynamodbazblobstorageazcosmosdbcassandraelasticgcshttpluascriptmongodbrediss3wasm
Launch the makecommand with the target compile and the plugins will be built in the build/ folder
The JR plugins should be in the internal/plugin package since they are not meant to be exposed externally.
To build a plugin someplugin the following steps are needed:
- create the package
internal/plugin/someplugin - implement the plugin in a file (e.g.
plugin.go) with the following requirements:
- the
plugin.gofile should have conditional build directives:
//go:build plugin_someplugin
// +build plugin_someplugin- a
doc.gowithout conditional build directives must be included (with the plugin documentation) - the plugin should implement the ´plugin.Plugin´ interface type:
type Plugin interface {
jrpc.Producer
Init(context.Context, []byte) error
}- in the
plugin.gofile register the plugin:
package someplugin
...
import (
"github.com/jrnd-io/jr-plugins/internal/plugin"
)
const (
Name = "someplugin"
)
func init() {
plugin.RegisterPlugin(Name, &Plugin{})
}
type Plugin struct{
...
}
func (p *Plugin) Init(ctx context.Context, cfgBytes []byte) error{
...
}
func (p *Plugin) Produce(k []byte, v []byte, headers map[string]string) (*jrpc.ProduceResponse, error) {
...
}- add the
somepluginpackage to the import in therun.gofile:
package main
import(
...
_ "github.com/jrnd-io/jr-plugins/internal/plugin/someplugin"
)- add
somepluginto the list of plugins in `Makefile``
PLUGINS=mongodb \
azblobstorage \
azcosmosdb \
luascript \
awsdynamodb \
s3 \
cassandra \
gcs \
elastic \
redis \
http \
someplugin