plugin

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PluginTypeName

func PluginTypeName(pluginType PluginType) string

func PopulateCmdlineOptions

func PopulateCmdlineOptions(fs *pflag.FlagSet) error

func ProcessConfig

func ProcessConfig(
	pluginConfig map[string]map[string]map[string]any,
) error

func ProcessEnvVars

func ProcessEnvVars() error

func Register

func Register(pluginEntry PluginEntry)

Register adds a plugin entry to the global registry. NOTE: This function is not thread-safe and should only be called during package initialization (e.g., in init() functions) before any concurrent goroutines begin. Concurrent access to pluginEntries is not protected.

func SetPluginOption added in v0.18.0

func SetPluginOption(
	pluginType PluginType,
	pluginName string,
	optionName string,
	value any,
) error

SetPluginOption sets the value of a named option for a plugin entry. This is used by callers that need to programmatically override plugin defaults (for example to set data-dir before starting a plugin). It returns an error if the plugin or option is not found or if the value type is incompatible. NOTE: This function accesses the global pluginEntries slice without synchronization. It should only be called during initialization or in single-threaded contexts to avoid race conditions. NOTE: This function writes directly to plugin option destinations (e.g., cmdlineOptions fields) without acquiring the plugin's cmdlineOptionsMutex. It must be called before any plugin instantiation to avoid data races with concurrent reads in NewFromCmdlineOptions.

Types

type ErrorPlugin added in v0.18.0

type ErrorPlugin struct {
	Err error
}

ErrorPlugin is a plugin that always returns an error on Start()

func (*ErrorPlugin) Start added in v0.18.0

func (e *ErrorPlugin) Start() error

func (*ErrorPlugin) Stop added in v0.18.0

func (e *ErrorPlugin) Stop() error

type Logger

type Logger interface {
	Info(string, ...any)
	Warn(string, ...any)
	Debug(string, ...any)
	Error(string, ...any)
}

Logger provides a logging interface for plugins.

type Plugin

type Plugin interface {
	Start() error
	Stop() error
}

func GetPlugin

func GetPlugin(pluginType PluginType, name string) Plugin

func NewErrorPlugin added in v0.18.0

func NewErrorPlugin(err error) Plugin

NewErrorPlugin creates a new error plugin that returns the given error on Start()

func StartPlugin added in v0.18.0

func StartPlugin(pluginType PluginType, pluginName string) (Plugin, error)

StartPlugin gets a plugin from the registry and starts it

type PluginEntry

type PluginEntry struct {
	NewFromOptionsFunc func() Plugin
	Name               string
	Description        string
	Options            []PluginOption
	Type               PluginType
}

func GetPlugins

func GetPlugins(pluginType PluginType) []PluginEntry

type PluginOption

type PluginOption struct {
	DefaultValue any
	Dest         any
	Name         string
	CustomEnvVar string
	CustomFlag   string
	Description  string
	Type         PluginOptionType
}

func (*PluginOption) AddToFlagSet

func (p *PluginOption) AddToFlagSet(
	fs *pflag.FlagSet,
	pluginType string,
	pluginName string,
) error

func (*PluginOption) ProcessConfig

func (p *PluginOption) ProcessConfig(
	pluginData map[string]any,
) error

func (*PluginOption) ProcessEnvVars

func (p *PluginOption) ProcessEnvVars(envPrefix string) error

type PluginOptionType

type PluginOptionType int
const (
	PluginOptionTypeString PluginOptionType = 1
	PluginOptionTypeBool   PluginOptionType = 2
	PluginOptionTypeInt    PluginOptionType = 3
	PluginOptionTypeUint   PluginOptionType = 4
)

type PluginType

type PluginType int
const (
	PluginTypeMetadata PluginType = 1
	PluginTypeBlob     PluginType = 2
)

Directories

Path Synopsis
aws
gcs

Jump to

Keyboard shortcuts

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