plugin

package
v0.0.1-alpha.5 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

README

Aethers Plugin Systems

We have based our plugin system off of hashicorps go-plugins. This was mainly so we could detach the need for matching dependencies. We use gRPC for communication

Example Plugin

There is an example plugin in the example directory with comments on the moving parts.

Install a Plugin

// TODO //

Create a Docker Image with your Plugin

// TODO //

Requirements for local setup

as we use gRPC and protobuffers, if you want to make changes to the .proto files you will need to install buf

go install github.com/bufbuild/buf/cmd/buf@v1.30.1
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.31.0

buf generate

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Handshake = plugin.HandshakeConfig{
	ProtocolVersion:  1,
	MagicCookieKey:   "AETHER_EXPORTER_PLUGIN",
	MagicCookieValue: "886c2a46-18b4-4090-8e13-0461439bb0d0",
}

Handshake is a common handshake that is shared by plugin and host. this is to make sure that versioning of plugins is equal and is not for security

Functions

This section is empty.

Types

type ExportPluginSystem

type ExportPluginSystem struct {
	Dir string

	Plugins []Exporter
}

ExportPluginSystem is used to manage all third party exporters

func (*ExportPluginSystem) Load

func (e *ExportPluginSystem) Load(ctx context.Context) error

Load goes to a directory and runs every binary in that directory as a plugin The plugins for the exporter will need to adhere to the ExporterPlugin interface else they will fail to load

type Exporter

type Exporter interface {
	Send(i *v1.Instance) error
}

Exporter is the interface that plugins need to adhere to

type ExporterPlugin

type ExporterPlugin struct {
	// GRPCPlugin must still implement the Plugin interface
	plugin.Plugin
	// Concrete implementation, written in Go. This is only used for plugins
	// that are written in Go.
	Impl Exporter
}

This is the implementation of plugin.GRPCPlugin so we can serve/consume this.

func (*ExporterPlugin) GRPCClient

func (p *ExporterPlugin) GRPCClient(
	ctx context.Context,
	broker *plugin.GRPCBroker,
	c *grpc.ClientConn,
) (interface{}, error)

GRPCClient returns a gRPC client

func (*ExporterPlugin) GRPCServer

func (p *ExporterPlugin) GRPCServer(
	broker *plugin.GRPCBroker,
	s *grpc.Server,
) error

GRPCServer is used to setup a GRPC server

type GRPCClient

type GRPCClient struct {
	// contains filtered or unexported fields
}

GRPCClient is an implementation of Exporter that can communicate over RPC

func (*GRPCClient) Send

func (g *GRPCClient) Send(i *v1.Instance) error

Send is used to fulfill the Exporter interface

type GRPCServer

type GRPCServer struct {
	Impl Exporter
}

GRPCServer is the gRPC server that GRPCClient talks to.

func (*GRPCServer) Send

func (m *GRPCServer) Send(
	ctx context.Context,
	req *proto.InstanceRequest) (*proto.Empty, error)

Send is used to receive the RPC requests

type PluginHandler

type PluginHandler struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(ctx context.Context, e *ExportPluginSystem) *PluginHandler

func (*PluginHandler) Handle

func (p *PluginHandler) Handle(ctx context.Context, e *bus.Event)

func (*PluginHandler) SendToExporters

func (p *PluginHandler) SendToExporters(ctx context.Context, e *bus.Event)

func (*PluginHandler) Stop

func (p *PluginHandler) Stop(ctx context.Context)

Directories

Path Synopsis
* This is a skeleton plugin that you can use to build an Aether ExporterPlugin * it is minimal with no functionality but adheres to the Aether plugin * interface
* This is a skeleton plugin that you can use to build an Aether ExporterPlugin * it is minimal with no functionality but adheres to the Aether plugin * interface

Jump to

Keyboard shortcuts

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