executor.go 535 B

1234567891011121314151617181920212223242526
  1. package tsdb
  2. import "context"
  3. type Executor interface {
  4. Execute(ctx context.Context, queries QuerySlice, query *QueryContext) *BatchResult
  5. }
  6. var registry map[string]GetExecutorFn
  7. type GetExecutorFn func(dsInfo *DataSourceInfo) Executor
  8. func init() {
  9. registry = make(map[string]GetExecutorFn)
  10. }
  11. func getExecutorFor(dsInfo *DataSourceInfo) Executor {
  12. if fn, exists := registry[dsInfo.PluginId]; exists {
  13. return fn(dsInfo)
  14. }
  15. return nil
  16. }
  17. func RegisterExecutor(pluginId string, fn GetExecutorFn) {
  18. registry[pluginId] = fn
  19. }