plugin

package
v3.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type Factory

type Factory interface {
	Validate(ctx context.Context, endpoint models.Endpoint) error
	Create(ctx context.Context, endpoint models.Endpoint) (Plugin, error)
}

Factory is the strict minimum interface used by

type MutableFactory

type MutableFactory interface {
	Validate(ctx context.Context, endpoint models.Endpoint) error
	Create(ctx context.Context, endpoint models.Endpoint) (Plugin, error)
	// Mutate will let a plugin customize what's being stored in the database.
	// It takes the endpoint as input and returns a json.RawMessage representing the plugin config as it will be stored in the database.
	// This is useful for plugins that need to encrypt some fields before storing them.
	Mutate(ctx context.Context, endpoint models.Endpoint) (json.RawMessage, error)
}

MutableFactory is an interface that plugins can used if they need to change the plugin configuration before storing it.

type Plugin

type Plugin interface {
	// Activate is called when the endpoint needs to be activated on the current host.
	// This method is called when the state machine transition to the ACTIVATED state.
	Activate(ctx context.Context) error

	// Disable is called when the endpoint needs to be disabled on the current host.
	// This method is called when the state machine transition from the ACTIVATED state to any other state.
	Deactivate(ctx context.Context) error

	// Ensure is called at regular interval when the endpoint is in the ACTIVATED state.
	Ensure(ctx context.Context) error

	// LockKey returns a string representing the key that represent the Endpoint.
	// This is the key that will be used for the primary election, all endpoints with the same key will be part of the same election.
	// Note: There's no prefix per plugin, if they same key is used by multiple plugins, they will all be part of the same election.
	ElectionKey(ctx context.Context) string
}

Plugin is an interface used by endpoint plugins to manage the actions needed to activate and deactivate an endpoint. A plugin is responsible for handling a single Endpoint.

type Registry

type Registry interface {
	Register(ctx context.Context, pluginName string, factory Factory)
	Create(ctx context.Context, endpoint models.Endpoint) (Plugin, error)
	Validate(ctx context.Context, endpoint models.Endpoint) error
	Mutate(ctx context.Context, endpoint models.Endpoint) (json.RawMessage, error)
}

func NewRegistry

func NewRegistry() Registry

Directories

Path Synopsis
Package pluginmock is a generated GoMock package.
Package pluginmock is a generated GoMock package.

Jump to

Keyboard shortcuts

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