mirror of
https://github.com/go-micro/go-micro.git
synced 2025-06-12 22:07:47 +02:00
Support plugin loading
This commit is contained in:
29
plugin/plugin.go
Normal file
29
plugin/plugin.go
Normal file
@ -0,0 +1,29 @@
|
||||
// Package plugin provides the ability to load plugins
|
||||
package plugin
|
||||
|
||||
// Plugin is a plugin loaded from a file
|
||||
type Plugin interface {
|
||||
// Initialise a plugin with the config
|
||||
Init(c *Config) error
|
||||
// Load loads a .so plugin at the given path
|
||||
Load(path string) (*Config, error)
|
||||
// Build a .so plugin with config at the path specified
|
||||
Build(path string, c *Config) error
|
||||
}
|
||||
|
||||
// Config is the plugin config
|
||||
type Config struct {
|
||||
// Name of the plugin e.g rabbitmq
|
||||
Name string
|
||||
// Type of the plugin e.g broker
|
||||
Type string
|
||||
// Path specifies the import path
|
||||
Path string
|
||||
// NewFunc creates an instance of the plugin
|
||||
NewFunc interface{}
|
||||
}
|
||||
|
||||
// NewPlugin creates a new plugin interface
|
||||
func NewPlugin() Plugin {
|
||||
return &plugin{}
|
||||
}
|
Reference in New Issue
Block a user