Move plugin context events into separate plugin
Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
@@ -34,7 +34,9 @@ type InitContext struct {
|
||||
Config interface{}
|
||||
Address string
|
||||
TTRPCAddress string
|
||||
Events *exchange.Exchange
|
||||
|
||||
// deprecated: will be removed in 2.0, use plugin.EventType
|
||||
Events *exchange.Exchange
|
||||
|
||||
Meta *Meta // plugins can fill in metadata at init.
|
||||
|
||||
@@ -135,6 +137,19 @@ func (i *InitContext) GetAll() []*Plugin {
|
||||
return i.plugins.ordered
|
||||
}
|
||||
|
||||
// GetByID returns the plugin of the given type and ID
|
||||
func (i *InitContext) GetByID(t Type, id string) (interface{}, error) {
|
||||
ps, err := i.GetByType(t)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
p, ok := ps[id]
|
||||
if !ok {
|
||||
return nil, errors.Wrapf(errdefs.ErrNotFound, "no %s plugins with id %s", t, id)
|
||||
}
|
||||
return p.Instance()
|
||||
}
|
||||
|
||||
// GetByType returns all plugins with the specific type.
|
||||
func (i *InitContext) GetByType(t Type) (map[string]*Plugin, error) {
|
||||
p, ok := i.plugins.byTypeAndID[t]
|
||||
|
Reference in New Issue
Block a user