2016-06-06 16:31:21 +08:00
|
|
|
package tsdb
|
|
|
|
|
|
2016-10-03 15:38:03 +08:00
|
|
|
import "context"
|
|
|
|
|
|
2016-06-06 16:31:21 +08:00
|
|
|
type Executor interface {
|
2016-10-03 15:38:03 +08:00
|
|
|
Execute(ctx context.Context, queries QuerySlice, context *QueryContext) *BatchResult
|
2016-06-06 16:31:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var registry map[string]GetExecutorFn
|
|
|
|
|
|
|
|
|
|
type GetExecutorFn func(dsInfo *DataSourceInfo) Executor
|
|
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
|
registry = make(map[string]GetExecutorFn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func getExecutorFor(dsInfo *DataSourceInfo) Executor {
|
2016-06-06 23:11:46 +08:00
|
|
|
if fn, exists := registry[dsInfo.PluginId]; exists {
|
2016-06-06 16:31:21 +08:00
|
|
|
return fn(dsInfo)
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-06 23:11:46 +08:00
|
|
|
func RegisterExecutor(pluginId string, fn GetExecutorFn) {
|
|
|
|
|
registry[pluginId] = fn
|
2016-06-06 16:31:21 +08:00
|
|
|
}
|