executor.go 490 B

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