Documentation
¶
Overview ¶
Package plugins provides a framework for dynamically loading and managing plugins
Index ¶
- func DownloadPlugin(url string, extension string) (string, error)
- func LoadPlugins(loader PluginLoader, config *Config) ([]schemas.Plugin, error)
- type Config
- type DynamicPlugin
- func (dp *DynamicPlugin) Cleanup() error
- func (dp *DynamicPlugin) GetName() string
- func (dp *DynamicPlugin) HTTPTransportPostHook(ctx *schemas.BifrostContext, req *schemas.HTTPRequest, ...) error
- func (dp *DynamicPlugin) HTTPTransportPreHook(ctx *schemas.BifrostContext, req *schemas.HTTPRequest) (*schemas.HTTPResponse, error)
- func (dp *DynamicPlugin) HTTPTransportStreamChunkHook(ctx *schemas.BifrostContext, req *schemas.HTTPRequest, ...) (*schemas.BifrostStreamChunk, error)
- func (dp *DynamicPlugin) PostHook(ctx *schemas.BifrostContext, resp *schemas.BifrostResponse, ...) (*schemas.BifrostResponse, *schemas.BifrostError, error)
- func (dp *DynamicPlugin) PreHook(ctx *schemas.BifrostContext, req *schemas.BifrostRequest) (*schemas.BifrostRequest, *schemas.PluginShortCircuit, error)
- type DynamicPluginConfig
- type PluginLoader
- type SharedObjectPluginLoader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DownloadPlugin ¶ added in v1.2.4
DownloadPlugin downloads a plugin from a URL and returns the local file path
func LoadPlugins ¶
func LoadPlugins(loader PluginLoader, config *Config) ([]schemas.Plugin, error)
LoadPlugins loads the plugins from the config
Types ¶
type Config ¶
type Config struct {
Plugins []DynamicPluginConfig `json:"plugins"`
}
Config is the configuration for the plugins framework
type DynamicPlugin ¶
type DynamicPlugin struct {
Enabled bool
Path string
Config any
// contains filtered or unexported fields
}
DynamicPlugin is the interface for a dynamic plugin
func (*DynamicPlugin) Cleanup ¶
func (dp *DynamicPlugin) Cleanup() error
Cleanup is invoked by core/bifrost.go during plugin unload, reload, and shutdown
func (*DynamicPlugin) GetName ¶
func (dp *DynamicPlugin) GetName() string
GetName returns the name of the plugin
func (*DynamicPlugin) HTTPTransportPostHook ¶ added in v1.2.9
func (dp *DynamicPlugin) HTTPTransportPostHook(ctx *schemas.BifrostContext, req *schemas.HTTPRequest, resp *schemas.HTTPResponse) error
HTTPTransportPostHook intercepts HTTP responses at the transport layer after exiting Bifrost core
func (*DynamicPlugin) HTTPTransportPreHook ¶ added in v1.2.9
func (dp *DynamicPlugin) HTTPTransportPreHook(ctx *schemas.BifrostContext, req *schemas.HTTPRequest) (*schemas.HTTPResponse, error)
HTTPTransportPreHook intercepts HTTP requests at the transport layer before entering Bifrost core
func (*DynamicPlugin) HTTPTransportStreamChunkHook ¶ added in v1.2.15
func (dp *DynamicPlugin) HTTPTransportStreamChunkHook(ctx *schemas.BifrostContext, req *schemas.HTTPRequest, stream *schemas.BifrostStreamChunk) (*schemas.BifrostStreamChunk, error)
HTTPTransportStreamChunkHook intercepts streaming chunks before they are written to the client
func (*DynamicPlugin) PostHook ¶
func (dp *DynamicPlugin) PostHook(ctx *schemas.BifrostContext, resp *schemas.BifrostResponse, bifrostErr *schemas.BifrostError) (*schemas.BifrostResponse, *schemas.BifrostError, error)
PostHook is invoked by PluginPipeline.RunPostHooks in core/bifrost.go
func (*DynamicPlugin) PreHook ¶
func (dp *DynamicPlugin) PreHook(ctx *schemas.BifrostContext, req *schemas.BifrostRequest) (*schemas.BifrostRequest, *schemas.PluginShortCircuit, error)
PreHook is invoked by PluginPipeline.RunPreHooks in core/bifrost.go
type DynamicPluginConfig ¶
type PluginLoader ¶ added in v1.2.4
PluginLoader is the contract for a plugin loader
type SharedObjectPluginLoader ¶ added in v1.2.4
type SharedObjectPluginLoader struct{}
SharedObjectPluginLoader is the loader for shared object plugins
func (*SharedObjectPluginLoader) LoadDynamicPlugin ¶ added in v1.2.4
func (l *SharedObjectPluginLoader) LoadDynamicPlugin(path string, config any) (schemas.Plugin, error)
LoadDynamicPlugin loads a dynamic plugin from a shared object file