plugin

package
v0.0.0-...-2c2b76d Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataObject

type DataObject struct {
	Plugin string `json:"plugin"`
	Value  string `json:"value"`
}

type IPogoPlugin

type IPogoPlugin interface {
	// Returns info about the plugin. Most importantly API version.
	Info() *PluginInfoRes

	// Executes a url-encoded json string, and returns one.
	Execute(req string) string

	// Notifies the plugin that a project exists. It is the plugin's responsibility
	// to decide when and to what extent action should be taken.
	ProcessProject(req *IProcessProjectReq) error
}

The interface that plugins should implement

type IProcessProjectReq

type IProcessProjectReq interface {
	Path() string
}

type PluginInfoRes

type PluginInfoRes struct {
	Version string `json:"version"`
}

type PluginRPC

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

Here is an implementation that talks over RPC

func (*PluginRPC) Execute

func (g *PluginRPC) Execute(req string) string

func (*PluginRPC) Info

func (g *PluginRPC) Info() *PluginInfoRes

func (*PluginRPC) ProcessProject

func (g *PluginRPC) ProcessProject(req *IProcessProjectReq) error

type PluginRPCServer

type PluginRPCServer struct {
	// This is the real implementation
	Impl IPogoPlugin
}

Here is the RPC server that PluginRPC talks to, conforming to the requirements of net/rpc

func (*PluginRPCServer) Execute

func (s *PluginRPCServer) Execute(req string, resp *string) error

func (*PluginRPCServer) Info

func (s *PluginRPCServer) Info(args interface{}, resp **PluginInfoRes) error

func (*PluginRPCServer) ProcessProject

func (s *PluginRPCServer) ProcessProject(args interface{}, resp *error) error

type PogoPlugin

type PogoPlugin struct {
	// Impl Injection
	Impl IPogoPlugin
}

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

This has two methods: Server must return an RPC server for this plugin type. We construct a PluginRPCServer for this.

Client must return an implementation of our interface that communicates over an RPC client. We return PluginRPC for this.

Ignore MuxBroker. That is used to create more multiplexed streams on our plugin connection and is a more advanced use case.

func (PogoPlugin) Client

func (PogoPlugin) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error)

func (*PogoPlugin) Server

func (p *PogoPlugin) Server(*plugin.MuxBroker) (interface{}, error)

type ProcessProjectReq

type ProcessProjectReq struct {
	PathVar string
}

func (ProcessProjectReq) Path

func (r ProcessProjectReq) Path() string

Jump to

Keyboard shortcuts

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