pluginapi

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package pluginapi provides the plugin interface for Hockeypuck with Interpose support

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventBus

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

EventBus handles event publishing and subscription

func NewEventBus

func NewEventBus() *EventBus

func (*EventBus) Publish

func (eb *EventBus) Publish(event PluginEvent) error

func (*EventBus) Subscribe

func (eb *EventBus) Subscribe(eventType string, handler func(PluginEvent) error) error

type HandlerPlugin

type HandlerPlugin interface {
	Plugin

	// Routes returns the routes this plugin wants to register
	Routes() []PluginRoute
}

HandlerPlugin is implemented by plugins that provide HTTP handlers

type Logger

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

Logger interface for plugin logging

type MiddlewarePlugin

type MiddlewarePlugin interface {
	Plugin

	// Middleware returns the middleware function for Interpose
	// Priority determines the order (lower numbers run first)
	Middleware() (func(http.Handler) http.Handler, int)
}

MiddlewarePlugin is implemented by plugins that provide HTTP middleware

type Plugin

type Plugin interface {
	// Initialize the plugin with server context and configuration
	Initialize(ctx context.Context, host PluginHost, config map[string]interface{}) error

	// Name returns the unique plugin identifier
	Name() string

	// Version returns the plugin version
	Version() string

	// Description returns human-readable plugin description
	Description() string

	// Dependencies returns required plugin dependencies
	Dependencies() []PluginDependency

	// Shutdown gracefully stops the plugin
	Shutdown(ctx context.Context) error
}

Plugin is the base interface that all plugins must implement

type PluginDependency

type PluginDependency struct {
	Name       string
	MinVersion string
}

PluginDependency represents a plugin dependency

type PluginEvent

type PluginEvent struct {
	Type      string
	Source    string
	Timestamp time.Time
	Data      interface{}
}

PluginEvent represents an event in the plugin system

type PluginHost

type PluginHost interface {
	// Access storage backend
	Storage() interface{}

	// Access configuration
	Config() interface{}

	// Access metrics system
	Metrics() interface{}

	// Register periodic tasks
	RegisterTask(name string, interval time.Duration, task func(context.Context) error) error

	// Publish events to plugin system
	PublishEvent(event PluginEvent) error

	// Subscribe to plugin events
	SubscribeEvent(eventType string, handler func(PluginEvent) error) error

	// Logger returns the plugin logger
	Logger() Logger
}

PluginHost provides server context and services to plugins

type PluginManager

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

PluginManager manages plugin lifecycle with Interpose

func NewPluginManager

func NewPluginManager(middleware *interpose.Middleware, logger Logger) *PluginManager

NewPluginManager creates a new plugin manager

func (*PluginManager) GetRoutes

func (pm *PluginManager) GetRoutes() map[string]http.HandlerFunc

GetRoutes returns all registered routes

func (*PluginManager) LoadPlugin

func (pm *PluginManager) LoadPlugin(ctx context.Context, plugin Plugin, config map[string]interface{}) error

LoadPlugin loads and initializes a plugin

func (*PluginManager) Shutdown

func (pm *PluginManager) Shutdown(ctx context.Context) error

Shutdown shuts down all plugins

type PluginRoute

type PluginRoute struct {
	Pattern string
	Handler http.HandlerFunc
	Methods []string // If empty, accepts all methods
}

PluginRoute defines a route that a plugin wants to register

Jump to

Keyboard shortcuts

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