Get returns the plugin given the specified name and requested implementation.
(name, imp string)
| 254 | |
| 255 | // Get returns the plugin given the specified name and requested implementation. |
| 256 | func Get(name, imp string) (*Plugin, error) { |
| 257 | if name == "" { |
| 258 | return nil, errors.New("Unable to find plugin without name") |
| 259 | } |
| 260 | pl, err := get(name) |
| 261 | if err != nil { |
| 262 | return nil, err |
| 263 | } |
| 264 | if err := pl.waitActive(); err == nil && pl.implements(imp) { |
| 265 | log.G(context.TODO()).Debugf("%s implements: %s", name, imp) |
| 266 | return pl, nil |
| 267 | } |
| 268 | return nil, fmt.Errorf("%w: plugin=%q, requested implementation=%q", ErrNotImplements, name, imp) |
| 269 | } |
| 270 | |
| 271 | // Handle adds the specified function to the extpointHandlers. |
| 272 | func Handle(iface string, fn func(string, *Client)) { |