plugin

package
v2.0.0-...-a21236f Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package plugin provides a hook system based on Hashicorp's plugin system. You can write a plugin in many languages. The plugin is then executed as a separate process and communicates with tusd over RPC. More details can be found at https://github.com/hashicorp/go-plugin. An example for a Go-based plugin implementation is at github.com/tus/tusd/examples/hooks/plugin.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupPlugins

func CleanupPlugins()

CleanupPlugins closes the connections to all plugins and ensures that their processes are properly stopped. You must call this function when the main process exits.

Types

type HookHandlerPlugin

type HookHandlerPlugin struct {
	// Impl Injection
	Impl hooks.HookHandler
}

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 HookHandlerRPCServer for this.

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

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

func (HookHandlerPlugin) Client

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

func (*HookHandlerPlugin) Server

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

type HookHandlerRPC

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

Here is an implementation that talks over RPC

func (*HookHandlerRPC) InvokeHook

func (g *HookHandlerRPC) InvokeHook(req hooks.HookRequest) (res hooks.HookResponse, err error)

func (*HookHandlerRPC) Setup

func (g *HookHandlerRPC) Setup() error

type HookHandlerRPCServer

type HookHandlerRPCServer struct {
	// This is the real implementation
	Impl hooks.HookHandler
}

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

func (*HookHandlerRPCServer) InvokeHook

func (s *HookHandlerRPCServer) InvokeHook(args hooks.HookRequest, resp *hooks.HookResponse) (err error)

func (*HookHandlerRPCServer) Setup

func (s *HookHandlerRPCServer) Setup(args interface{}, resp *interface{}) error

type PluginHook

type PluginHook struct {
	Path string
	// contains filtered or unexported fields
}

func (*PluginHook) InvokeHook

func (h *PluginHook) InvokeHook(req hooks.HookRequest) (hooks.HookResponse, error)

func (*PluginHook) Setup

func (h *PluginHook) Setup() error

Setup initiates the connection to the plugin. Note: When the main process ends, you must call CleanupClients() to ensure that the subprocess is properly cleaned up.

Jump to

Keyboard shortcuts

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