mirror of
https://github.com/go-micro/go-micro.git
synced 2025-07-06 22:35:51 +02:00
.github
agent
api
auth
broker
client
codec
config
debug
errors
logger
metadata
network
plugin
default.go
plugin.go
template.go
proxy
registry
router
runtime
server
service
store
sync
transport
tunnel
util
web
.gitignore
.golangci.yml
CNAME
Dockerfile
LICENSE
README.md
README.zh-cn.md
_config.yml
defaults.go
event.go
function.go
function_test.go
generate.go
go.mod
go.sum
micro.go
options.go
service.go
service_test.go
47 lines
1021 B
Go
47 lines
1021 B
Go
// 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{}
|
|
}
|
|
|
|
var (
|
|
// Default plugin loader
|
|
DefaultPlugin = NewPlugin()
|
|
)
|
|
|
|
// NewPlugin creates a new plugin interface
|
|
func NewPlugin() Plugin {
|
|
return &plugin{}
|
|
}
|
|
|
|
func Build(path string, c *Config) error {
|
|
return DefaultPlugin.Build(path, c)
|
|
}
|
|
|
|
func Load(path string) (*Config, error) {
|
|
return DefaultPlugin.Load(path)
|
|
}
|
|
|
|
func Init(c *Config) error {
|
|
return DefaultPlugin.Init(c)
|
|
}
|