plugin

package
v0.0.0-...-b6acc2a Latest Latest
Warning

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

Go to latest
Published: May 15, 2023 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPluginNotFound = errors.New("plugin not found")

ErrPluginNotFound is returned when a plugin is not found.

View Source
var ErrUnexpectedInterface = errors.New("unexpected interface")

ErrUnexpectedInterface is returned when the plugin does not support the expected interface.

View Source
var ErrUnsupportedPluginInterface = fmt.Errorf("unsupported plugin interface")

ErrUnsupportedPluginInterface is returned when an interface is requested that is not supported.

Functions

func DiscoverPlugins

func DiscoverPlugins(dirs []string) ([]string, error)

DiscoverPlugins looks for available plugins in the provided directories.

func Factory

func Factory(ctx context.Context, path string, interfaces []string) (*plugin.Client, error)

Factory is a factory for creating plugin clients for the interfaces requested.

func FindPlugins

func FindPlugins(dirs []string) ([]string, error)

FindPlugins looks for available plugins in the same directory as the exeuatable or in the provided directories.

func Interfaces

func Interfaces(ctx context.Context, path string) ([]string, error)

Intrerfaces discovers the interfaces supported by the plugin.

func ResolvePlugins

func ResolvePlugins(dirs []string) (map[string]string, error)

ResolvePlugins resolves all plugins found in the provided directories and returns a `map[string]string` containing all plugins names and their path.

Types

type Manager

type Manager struct {
	Clients map[string]*plugin.Client
	Dirs    []string
	// contains filtered or unexported fields
}

func NewManager

func NewManager(dirs ...string) *Manager

func (*Manager) Client

func (manager *Manager) Client(ctx context.Context, name string) (*plugin.Client, error)

Client returns a client for the given plugin.

func (*Manager) Close

func (manager *Manager) Close()

Close closes all plugin clients.

func (*Manager) Interfaces

func (manager *Manager) Interfaces(ctx context.Context, name string) ([]string, error)

Interfaces returns a list of interfaces for a given plugin.

func (*Manager) ResolvePlugin

func (manager *Manager) ResolvePlugin(ctx context.Context, name string) (string, error)

ResolvePlugin resolves a plugin name to a path.

Jump to

Keyboard shortcuts

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