plugin_protocol

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: MPL-2.0 Imports: 4 Imported by: 0

README

plugin-protocol

The gRPC protocol used by plugins of Saturn.

The protocol is defined in protobuf for use by go-plugin.

Plugin SDKs that implement the protocol can use the integration test suite to verify the implementation. The directory features contains the test suite.

To execute the integration tests, ensure that the command saturn is available in $PATH and execute the tests:

go install codeberg.org/saturn-sync/saturn@latest
go test -plugin-path <path to plugin integration test implementation>

Documentation

Index

Constants

View Source
const (
	ID = "saturn-bot-plugin"
)

Variables

View Source
var Handshake = plugin.HandshakeConfig{
	ProtocolVersion:  1,
	MagicCookieKey:   "SATURN_PLUGIN_MAGIC_COOKIE",
	MagicCookieValue: "9P59IdZaEoZpENXXY2SHuvjczxUVHJaVhGG8RgeIVXfPx6c5wt34g6NLtRNehFT6",
}

Handshake defines settings used by the client and server of go-plugin.

View Source
var PluginMap = map[string]plugin.Plugin{
	ID: &ProviderPlugin{},
}

PluginMap defines the mapping of plugin ID to the actual implementation. It is used by client and server implementations to identify which go-plugin to call or start, respectively.

Functions

This section is empty.

Types

type Provider

type Provider interface {
	ExecuteActions(*protocolv1.ExecuteActionsRequest) (*protocolv1.ExecuteActionsResponse, error)
	ExecuteFilters(*protocolv1.ExecuteFiltersRequest) (*protocolv1.ExecuteFiltersResponse, error)
	GetPlugin(*protocolv1.GetPluginRequest) (*protocolv1.GetPluginResponse, error)
	OnPrClosed(*protocolv1.OnPrClosedRequest) (*protocolv1.OnPrClosedResponse, error)
	OnPrCreated(*protocolv1.OnPrCreatedRequest) (*protocolv1.OnPrCreatedResponse, error)
	OnPrMerged(*protocolv1.OnPrMergedRequest) (*protocolv1.OnPrMergedResponse, error)
	Shutdown(*protocolv1.ShutdownRequest) (*protocolv1.ShutdownResponse, error)
}

Provider defines the methods to call remote code via go-plugin.

type ProviderGrpcClient

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

ProviderGrpcClient provides the implementation of the gRPC plugin client. codeberg.org/saturn-sync/saturn uses this implementation to connect to a plugin process.

func (*ProviderGrpcClient) ExecuteActions

func (*ProviderGrpcClient) ExecuteFilters

func (*ProviderGrpcClient) GetPlugin

func (*ProviderGrpcClient) OnPrClosed

func (*ProviderGrpcClient) OnPrCreated

func (*ProviderGrpcClient) OnPrMerged

func (*ProviderGrpcClient) Shutdown

type ProviderGrpcServer

type ProviderGrpcServer struct {
	protocolv1.UnimplementedPluginServiceServer
	Impl Provider
}

ProviderGrpcServer connects the gRPC server with the implementation of the rpc methods. The Go plugin SDK defines the implementation.

func (*ProviderGrpcServer) ExecuteActions

ExecuteActions implements Provider.

func (*ProviderGrpcServer) ExecuteFilters

ExecuteFilters implements Provider.

func (*ProviderGrpcServer) GetPlugin

GetPlugin implements Provider.

func (*ProviderGrpcServer) OnPrClosed

OnPrClosed implements Provider.

func (*ProviderGrpcServer) OnPrCreated

OnPrCreated implements Provider.

func (*ProviderGrpcServer) OnPrMerged

OnPrMerged implements Provider.

func (*ProviderGrpcServer) Shutdown

Shutdown implements Provider.

type ProviderPlugin

type ProviderPlugin struct {
	plugin.Plugin
	Impl Provider
}

ProviderPlugin is the bridge between custom code and go-plugin.

func (*ProviderPlugin) GRPCClient

func (p *ProviderPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)

GRPCClient implements plugin.GRPCPlugin. go-plugin uses this method under the hood to instantiate a plugin client.

https://github.com/hashicorp/go-plugin/blob/8d2aaa458971cba97c3bfec1b0380322e024b514/plugin.go#L36C6-L36C16

func (*ProviderPlugin) GRPCServer

func (p *ProviderPlugin) GRPCServer(_ *plugin.GRPCBroker, s *grpc.Server) error

GRPCServer implements plugin.GRPCPlugin. The Saturn Go plugin SDK uses this method to start the plugin process.

https://github.com/hashicorp/go-plugin/blob/8d2aaa458971cba97c3bfec1b0380322e024b514/plugin.go#L36C6-L36C16

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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