Documentation ¶
Index ¶
- Constants
- Variables
- func SetupFillmode(query *backend.DataQuery, interval time.Duration, fillmode string) error
- type DBDataResponse
- type DataPluginConfiguration
- type DataSourceHandler
- type DataSourceInfo
- type DefaultConnectionInfo
- type JsonData
- type QueryJson
- type SQLMacroEngine
- type SQLMacroEngineBase
- type SqlQueryResultTransformer
Constants ¶
View Source
const MetaKeyExecutedQueryString = "executedQueryString"
MetaKeyExecutedQueryString is the key where the executed query should get stored
Variables ¶
View Source
var ErrConnectionFailed = errutil.NewBase(errutil.StatusInternal, "sqleng.connectionError")
View Source
var Interpolate = func(query backend.DataQuery, timeRange backend.TimeRange, timeInterval string, sql string) (string, error) { minInterval, err := intervalv2.GetIntervalFrom(timeInterval, query.Interval.String(), query.Interval.Milliseconds(), time.Second*60) if err != nil { return "", err } interval := sqlIntervalCalculator.Calculate(timeRange, minInterval, query.MaxDataPoints) sql = strings.ReplaceAll(sql, "$__interval_ms", strconv.FormatInt(interval.Milliseconds(), 10)) sql = strings.ReplaceAll(sql, "$__interval", interval.Text) sql = strings.ReplaceAll(sql, "$__unixEpochFrom()", fmt.Sprintf("%d", timeRange.From.UTC().Unix())) sql = strings.ReplaceAll(sql, "$__unixEpochTo()", fmt.Sprintf("%d", timeRange.To.UTC().Unix())) return sql, nil }
Interpolate provides global macros/substitutions for all sql datasources.
View Source
var NewXormEngine = func(driverName string, connectionString string) (*xorm.Engine, error) { return xorm.NewEngine(driverName, connectionString) }
NewXormEngine is an xorm.Engine factory, that can be stubbed by tests.
View Source
var XormDriverMu sync.RWMutex
XormDriverMu is used to allow safe concurrent registering and querying of drivers in xorm
Functions ¶
Types ¶
type DBDataResponse ¶
type DBDataResponse struct {
// contains filtered or unexported fields
}
type DataPluginConfiguration ¶
type DataSourceHandler ¶
type DataSourceHandler struct {
// contains filtered or unexported fields
}
func NewQueryDataHandler ¶
func NewQueryDataHandler(cfg *setting.Cfg, config DataPluginConfiguration, queryResultTransformer SqlQueryResultTransformer, macroEngine SQLMacroEngine, log log.Logger) (*DataSourceHandler, error)
func (*DataSourceHandler) Dispose ¶
func (e *DataSourceHandler) Dispose()
func (*DataSourceHandler) Ping ¶
func (e *DataSourceHandler) Ping() error
func (*DataSourceHandler) QueryData ¶
func (e *DataSourceHandler) QueryData(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error)
func (*DataSourceHandler) TransformQueryError ¶
func (e *DataSourceHandler) TransformQueryError(logger log.Logger, err error) error
type DataSourceInfo ¶
type DefaultConnectionInfo ¶
Defaults for the xorm connection pool
type JsonData ¶
type JsonData struct { MaxOpenConns int `json:"maxOpenConns"` MaxIdleConns int `json:"maxIdleConns"` ConnMaxLifetime int `json:"connMaxLifetime"` ConnectionTimeout int `json:"connectionTimeout"` Timescaledb bool `json:"timescaledb"` Mode string `json:"sslmode"` ConfigurationMethod string `json:"tlsConfigurationMethod"` TlsSkipVerify bool `json:"tlsSkipVerify"` RootCertFile string `json:"sslRootCertFile"` CertFile string `json:"sslCertFile"` CertKeyFile string `json:"sslKeyFile"` Timezone string `json:"timezone"` Encrypt string `json:"encrypt"` Servername string `json:"servername"` TimeInterval string `json:"timeInterval"` Database string `json:"database"` SecureDSProxy bool `json:"enableSecureSocksProxy"` AllowCleartextPasswords bool `json:"allowCleartextPasswords"` }
type SQLMacroEngine ¶
type SQLMacroEngine interface {
Interpolate(query *backend.DataQuery, timeRange backend.TimeRange, sql string) (string, error)
}
SQLMacroEngine interpolates macros into sql. It takes in the Query to have access to query context and timeRange to be able to generate queries that use from and to.
type SQLMacroEngineBase ¶
type SQLMacroEngineBase struct{}
func NewSQLMacroEngineBase ¶
func NewSQLMacroEngineBase() *SQLMacroEngineBase
func (*SQLMacroEngineBase) ReplaceAllStringSubmatchFunc ¶
type SqlQueryResultTransformer ¶
type SqlQueryResultTransformer interface { // TransformQueryError transforms a query error. TransformQueryError(logger log.Logger, err error) error GetConverterList() []sqlutil.StringConverter }
SqlQueryResultTransformer transforms a query result row to RowValues with proper types.
Click to show internal directories.
Click to hide internal directories.