23 lines
406 B
Go
23 lines
406 B
Go
package shared
|
|
|
|
import (
|
|
"github.com/hashicorp/go-plugin"
|
|
)
|
|
|
|
type Plugin struct {
|
|
Tag string
|
|
P PluginService
|
|
}
|
|
|
|
func NewPlugin(p PluginService, tag string) *Plugin {
|
|
return &Plugin{P: p, Tag: tag}
|
|
}
|
|
|
|
func PluginSet(opts ...*Plugin) plugin.PluginSet {
|
|
plugins := make(map[string]plugin.Plugin, len(opts))
|
|
for _, opt := range opts {
|
|
plugins[opt.Tag] = &GRPCPlugin{Impl: opt.P}
|
|
}
|
|
return plugins
|
|
}
|