Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrorBadDatasource ... ErrorBadDatasource = errors.New("type assertion to datasource failed") // ErrorJSON is returned when json.Unmarshal fails ErrorJSON = errors.New("error unmarshaling query JSON the Query Model") // ErrorQuery is returned when the query could not complete / execute ErrorQuery = errors.New("error querying the database") )
var ( // ErrorBadArgumentCount is returned from macros when the wrong number of arguments were provided ErrorBadArgumentCount = errors.New("unexpected number of arguments") )
Functions ¶
func NewDatasource ¶
func NewDatasource(c Driver) *sqldatasource
NewDatasource initializes the Datasource wrapper and instance manager
Types ¶
type Completable ¶ added in v1.2.0
type Completable interface {
Schemas(ctx context.Context) ([]string, error)
Tables(ctx context.Context, schema string) ([]string, error)
Columns(ctx context.Context, table string) ([]string, error)
}
Completable will be used to autocomplete Tables Schemas and Columns for SQL languages
type Driver ¶
type Driver interface {
// Connect connects to the database. It does not need to call `db.Ping()`
Connect(backend.DataSourceInstanceSettings) (*sql.DB, error)
FillMode() *data.FillMissing
Macros() Macros
Converters() []sqlutil.Converter
}
Driver is a simple interface that defines how to connect to a backend SQL datasource Plugin creators will need to implement this in order to create a managed datasource
type FormatQueryOption ¶
type FormatQueryOption uint32
FormatQueryOption defines how the user has chosen to represent the data
const ( // FormatOptionTimeSeries formats the query results as a timeseries using "WideToLong" FormatOptionTimeSeries FormatQueryOption = iota // FormatOptionTable formats the query results as a table using "LongToWide" FormatOptionTable )
type MacroFunc ¶
MacroFunc defines a signature for applying a query macro Query macro implementations are defined by users / consumers of this package
type Macros ¶
Macros is a list of MacroFuncs. The "string" key is the name of the macro function. This name has to be regex friendly.
type Query ¶
type Query struct {
RawSQL string `json:"rawSql"`
Format FormatQueryOption `json:"format"`
RefID string `json:"-"`
Interval time.Duration `json:"-"`
TimeRange backend.TimeRange `json:"-"`
MaxDataPoints int64 `json:"-"`
FillMissing *data.FillMissing `json:"fillMode,omitempty"`
// Macros
Schema string `json:"schema,omitempty"`
Table string `json:"table,omitempty"`
Column string `json:"column,omitempty"`
}
Query is the model that represents the query that users submit from the panel / queryeditor. For the sake of backwards compatibility, when making changes to this type, ensure that changes are only additive.
type Response ¶ added in v1.1.0
type Response struct {
// contains filtered or unexported fields
}
func NewResponse ¶ added in v1.1.0
func NewResponse(res *backend.QueryDataResponse) *Response
func (*Response) Response ¶ added in v1.1.0
func (r *Response) Response() *backend.QueryDataResponse