package plugin import ( "fmt" "sync" ) type PluginStore struct { m sync.RWMutex plugins map[string]*Plugin } func NewPluginStore() *PluginStore { return &PluginStore{ plugins: make(map[string]*Plugin), } } func (s *PluginStore) Add(plugin *Plugin) { s.m.Lock() defer s.m.Unlock() s.plugins[PluginStoreKey(plugin.md.Namespace, plugin.md.Name, plugin.md.Version)] = plugin } func PluginStoreKey(ns, name string, v int) string { return fmt.Sprintf("%s.%s.%v", ns, name, v) }