(found map[string]string, done map[string][]string)
| 155 | } |
| 156 | |
| 157 | func (o *Options) loadPlugins(found map[string]string, done map[string][]string) error { |
| 158 | for _, plug := range o.Plugins { |
| 159 | name := plug[0] |
| 160 | path, ok := found[name] |
| 161 | if !ok { |
| 162 | return fmt.Errorf("multitype plugin %s not found in plugin dirs", name) |
| 163 | } |
| 164 | fltrs, preds, dcs, err := loadPlugin(path, plug[1:]) |
| 165 | if err != nil { |
| 166 | return fmt.Errorf("failed to load plugin %s: %s", path, err) |
| 167 | } |
| 168 | |
| 169 | o.CustomFilters = append(o.CustomFilters, fltrs...) |
| 170 | o.CustomPredicates = append(o.CustomPredicates, preds...) |
| 171 | o.CustomDataClients = append(o.CustomDataClients, dcs...) |
| 172 | log.Printf("multitype plugin %s loaded from %s (filter: %d, predicate: %d, dataclient: %d)", |
| 173 | name, path, len(fltrs), len(preds), len(dcs)) |
| 174 | markPluginLoaded(done, name, "InitPlugin") |
| 175 | } |
| 176 | return nil |
| 177 | } |
| 178 | |
| 179 | func loadPlugin(path string, args []string) ([]filters.Spec, []routing.PredicateSpec, []routing.DataClient, error) { |
| 180 | mod, err := plugin.Open(path) |
no test coverage detected