|
@@ -43,7 +43,7 @@ type plugins struct {
|
|
|
|
|
|
var (
|
|
var (
|
|
storage = plugins{plugins: make(map[string]*Plugin)}
|
|
storage = plugins{plugins: make(map[string]*Plugin)}
|
|
- extpointHandlers = make(map[string]func(string, *Client))
|
|
|
|
|
|
+ extpointHandlers = make(map[string][]func(string, *Client))
|
|
)
|
|
)
|
|
|
|
|
|
// Manifest lists what a plugin implements.
|
|
// Manifest lists what a plugin implements.
|
|
@@ -129,11 +129,13 @@ func (p *Plugin) activateWithLock() error {
|
|
p.Manifest = m
|
|
p.Manifest = m
|
|
|
|
|
|
for _, iface := range m.Implements {
|
|
for _, iface := range m.Implements {
|
|
- handler, handled := extpointHandlers[iface]
|
|
|
|
|
|
+ handlers, handled := extpointHandlers[iface]
|
|
if !handled {
|
|
if !handled {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- handler(p.name, p.client)
|
|
|
|
|
|
+ for _, handler := range handlers {
|
|
|
|
+ handler(p.name, p.client)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
@@ -226,7 +228,16 @@ func Get(name, imp string) (*Plugin, error) {
|
|
|
|
|
|
// Handle adds the specified function to the extpointHandlers.
|
|
// Handle adds the specified function to the extpointHandlers.
|
|
func Handle(iface string, fn func(string, *Client)) {
|
|
func Handle(iface string, fn func(string, *Client)) {
|
|
- extpointHandlers[iface] = fn
|
|
|
|
|
|
+ handlers, ok := extpointHandlers[iface]
|
|
|
|
+ if !ok {
|
|
|
|
+ handlers = []func(string, *Client){}
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ handlers = append(handlers, fn)
|
|
|
|
+ extpointHandlers[iface] = handlers
|
|
|
|
+ for _, p := range storage.plugins {
|
|
|
|
+ p.activated = false
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
// GetAll returns all the plugins for the specified implementation
|
|
// GetAll returns all the plugins for the specified implementation
|