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

plugin

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FetcherPlugin

type FetcherPlugin interface {
	Plugin
	Fetch(ctx context.Context, req *types.Request) (*types.Response, error)
}

FetcherPlugin extends the fetcher layer.

type HookPlugin

type HookPlugin interface {
	Plugin
	OnStart() error
	OnStop() error
	OnRequest(req *types.Request) error
	OnResponse(resp *types.Response) error
	OnItem(item *types.Item) error
	OnError(err error)
}

HookPlugin receives lifecycle events.

type MiddlewarePlugin

type MiddlewarePlugin interface {
	Plugin
	Process(item *types.Item) (*types.Item, error)
}

MiddlewarePlugin extends the pipeline.

type ParserPlugin

type ParserPlugin interface {
	Plugin
	Parse(resp *types.Response, rules []config.ParseRule) ([]*types.Item, []string, error)
}

ParserPlugin extends the parser layer.

type Plugin

type Plugin interface {
	Name() string
	Type() PluginType
	Version() string
	Init(cfg map[string]any) error
	Close() error
}

Plugin is the base interface all plugins must implement.

type PluginInfo

type PluginInfo struct {
	Name    string     `json:"name"`
	Type    PluginType `json:"type"`
	Version string     `json:"version"`
}

PluginInfo holds summary information about a plugin.

type PluginType

type PluginType string

PluginType identifies the category of a plugin.

const (
	PluginTypeFetcher    PluginType = "fetcher"
	PluginTypeParser     PluginType = "parser"
	PluginTypeMiddleware PluginType = "middleware"
	PluginTypeStorage    PluginType = "storage"
	PluginTypeHook       PluginType = "hook"
)

type Registry

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

Registry manages plugin registration and discovery.

func NewRegistry

func NewRegistry(logger *slog.Logger) *Registry

NewRegistry creates a new plugin registry.

func (*Registry) CloseAll

func (r *Registry) CloseAll()

CloseAll closes all registered plugins.

func (*Registry) Get

func (r *Registry) Get(name string) (Plugin, bool)

Get returns a plugin by name.

func (*Registry) GetByType

func (r *Registry) GetByType(t PluginType) []Plugin

GetByType returns all plugins of a given type.

func (*Registry) InitAll

func (r *Registry) InitAll(configs map[string]map[string]any) error

InitAll initializes all registered plugins with their configs.

func (*Registry) List

func (r *Registry) List() []PluginInfo

List returns all registered plugins.

func (*Registry) Register

func (r *Registry) Register(p Plugin) error

Register adds a plugin to the registry.

func (*Registry) RunHooks

func (r *Registry) RunHooks(fn func(HookPlugin) error)

RunHooks executes a hook function on all HookPlugins.

func (*Registry) Unregister

func (r *Registry) Unregister(name string) error

Unregister removes a plugin from the registry.

type StoragePlugin

type StoragePlugin interface {
	Plugin
	Store(items []*types.Item) error
}

StoragePlugin extends storage backends.

Directories

Path Synopsis
Package plugin/sdk provides helper types and functions for building ScrapeGoat plugins using the init() registration pattern.
Package plugin/sdk provides helper types and functions for building ScrapeGoat plugins using the init() registration pattern.

Jump to

Keyboard shortcuts

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