Help us shape the future of Go! Take the 2026 Go Developer Survey

plugin

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HandshakeConfig = hplugin.HandshakeConfig{
	ProtocolVersion:  1,
	MagicCookieKey:   "CHEST_PLUGIN",
	MagicCookieValue: "CHEST_IN_A_CHEST",
}

HandshakeConfig ensures plugin and host agree on protocol

View Source
var PluginMap = map[string]hplugin.Plugin{
	"classifier": &ClassifierPluginRPC{},
}

PluginMap maps plugin types to implementations

Functions

func ClassifyWithPlugins

func ClassifyWithPlugins(services []ClassifierService, filename, ext string) string

ClassifyWithPlugins tries each loaded plugin service to classify a file. Returns the first non-empty, non-"Other" result, or empty string if no plugin matched.

Types

type ClassifierPluginRPC

type ClassifierPluginRPC struct {
	Impl ClassifierService
}

func (*ClassifierPluginRPC) Client

func (p *ClassifierPluginRPC) Client(b *hplugin.MuxBroker, c *rpc.Client) (interface{}, error)

func (*ClassifierPluginRPC) Server

func (p *ClassifierPluginRPC) Server(*hplugin.MuxBroker) (interface{}, error)

type ClassifierRPCClient

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

RPC Server/Client implementation

func (*ClassifierRPCClient) Classify

func (c *ClassifierRPCClient) Classify(filename string, ext string) (string, error)

func (*ClassifierRPCClient) GetCustomRules

func (c *ClassifierRPCClient) GetCustomRules() ([]models.Rule, error)

func (*ClassifierRPCClient) GetInfo

func (c *ClassifierRPCClient) GetInfo() (Manifest, error)

type ClassifierRPCServer

type ClassifierRPCServer struct {
	Impl ClassifierService
}

func (*ClassifierRPCServer) Classify

func (s *ClassifierRPCServer) Classify(args []string, resp *string) error

func (*ClassifierRPCServer) GetCustomRules

func (s *ClassifierRPCServer) GetCustomRules(args interface{}, resp *[]models.Rule) error

func (*ClassifierRPCServer) GetInfo

func (s *ClassifierRPCServer) GetInfo(args interface{}, resp *Manifest) error

type ClassifierService

type ClassifierService interface {
	GetInfo() (Manifest, error)
	Classify(filename string, ext string) (string, error)
	GetCustomRules() ([]models.Rule, error)
}

ClassifierService is the interface exposed by plugins

type Manager

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

Manager discovers and manages local plugins

func NewManager

func NewManager(customDir ...string) (*Manager, error)

NewManager creates a plugin manager pointing to target directory (default ~/.chest/plugins)

func (*Manager) GetInfo

func (m *Manager) GetInfo(name string) (*Manifest, error)

GetInfo retrieves manifest for specific plugin

func (*Manager) GetPluginDir

func (m *Manager) GetPluginDir() string

GetPluginDir returns plugin storage folder

func (*Manager) Install

func (m *Manager) Install(sourcePath string) (*Manifest, error)

Install installs a plugin from a local directory containing manifest.toml or manifest.json

func (*Manager) List

func (m *Manager) List() ([]Manifest, error)

List installed plugins by reading manifest.toml or manifest.json in each plugin folder

func (*Manager) LoadAllClassifiers

func (m *Manager) LoadAllClassifiers() ([]ClassifierService, []models.Rule, func())

LoadAllClassifiers discovers all installed plugins with "classifier" capability, spawns each one, collects custom rules via GetCustomRules(), and returns:

  • services: slice of active ClassifierService instances
  • rules: aggregated custom rules from all plugins
  • cleanup: function to kill all spawned plugin processes

func (*Manager) LoadClassifier

func (m *Manager) LoadClassifier(name string) (ClassifierService, func(), error)

LoadClassifier spawns external plugin process and returns client

func (*Manager) Remove

func (m *Manager) Remove(name string) error

Remove uninstalls a plugin

type Manifest

type Manifest struct {
	Name         string   `json:"name" toml:"name"`
	Version      string   `json:"version" toml:"version"`
	Description  string   `json:"description" toml:"description"`
	Author       string   `json:"author,omitempty" toml:"author,omitempty"`
	Capabilities []string `json:"capabilities" toml:"capabilities"` // e.g. ["classifier", "preset", "rule"]
	Binary       string   `json:"binary" toml:"binary"`             // executable filename
}

Manifest represents plugin metadata stored in manifest.json, manifest.toml, or returned by plugin

Jump to

Keyboard shortcuts

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