Documentation
¶
Index ¶
- type FetcherPlugin
- type HookPlugin
- type MiddlewarePlugin
- type ParserPlugin
- type Plugin
- type PluginInfo
- type PluginType
- type Registry
- func (r *Registry) CloseAll()
- func (r *Registry) Get(name string) (Plugin, bool)
- func (r *Registry) GetByType(t PluginType) []Plugin
- func (r *Registry) InitAll(configs map[string]map[string]any) error
- func (r *Registry) List() []PluginInfo
- func (r *Registry) Register(p Plugin) error
- func (r *Registry) RunHooks(fn func(HookPlugin) error)
- func (r *Registry) Unregister(name string) error
- type StoragePlugin
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 ¶
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 ¶
NewRegistry creates a new plugin registry.
func (*Registry) GetByType ¶
func (r *Registry) GetByType(t PluginType) []Plugin
GetByType returns all plugins of a given type.
func (*Registry) RunHooks ¶
func (r *Registry) RunHooks(fn func(HookPlugin) error)
RunHooks executes a hook function on all HookPlugins.
func (*Registry) Unregister ¶
Unregister removes a plugin from the registry.
Click to show internal directories.
Click to hide internal directories.