mirror of
https://github.com/grafana/grafana.git
synced 2025-07-30 00:52:16 +08:00

* WIP * Update yarn.lock * Align uuid dependency * Add e2e test and update * Update cue version * Fix lint * Update snapshot test * Fix test that was importing from coupled module * Fix lint * Update public/app/plugins/datasource/loki/package.json Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com> --------- Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com>
41 lines
1.3 KiB
Go
41 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
|
"github.com/grafana/grafana-plugin-sdk-go/backend/httpclient"
|
|
"github.com/grafana/grafana-plugin-sdk-go/backend/instancemgmt"
|
|
"github.com/grafana/grafana-plugin-sdk-go/backend/tracing"
|
|
|
|
loki "github.com/grafana/grafana/pkg/tsdb/loki"
|
|
)
|
|
|
|
var (
|
|
_ backend.QueryDataHandler = (*Datasource)(nil)
|
|
_ backend.CheckHealthHandler = (*Datasource)(nil)
|
|
_ backend.CallResourceHandler = (*Datasource)(nil)
|
|
)
|
|
|
|
func NewDatasource(context.Context, backend.DataSourceInstanceSettings) (instancemgmt.Instance, error) {
|
|
return &Datasource{
|
|
Service: loki.ProvideService(httpclient.NewProvider(), tracing.DefaultTracer()),
|
|
}, nil
|
|
}
|
|
|
|
type Datasource struct {
|
|
Service *loki.Service
|
|
}
|
|
|
|
func (d *Datasource) QueryData(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) {
|
|
return d.Service.QueryData(ctx, req)
|
|
}
|
|
|
|
func (d *Datasource) CallResource(ctx context.Context, req *backend.CallResourceRequest, sender backend.CallResourceResponseSender) error {
|
|
return d.Service.CallResource(ctx, req, sender)
|
|
}
|
|
|
|
func (d *Datasource) CheckHealth(ctx context.Context, req *backend.CheckHealthRequest) (*backend.CheckHealthResult, error) {
|
|
return d.Service.CheckHealth(ctx, req)
|
|
}
|