Commit 05ed7811 by Ryan McKinley Committed by GitHub

InfluxDB: use released client 1.3.0 (#25725)

parent b5b019df
......@@ -35,7 +35,7 @@ require (
github.com/hashicorp/go-plugin v1.2.2
github.com/hashicorp/go-version v1.1.0
github.com/inconshreveable/log15 v0.0.0-20180818164646-67afb5ed74ec
github.com/influxdata/influxdb-client-go v1.1.1-0.20200511153144-e63a28ffeba7
github.com/influxdata/influxdb-client-go v1.3.0
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af
github.com/jung-kurt/gofpdf v1.10.1
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 // indirect
......
......@@ -4,7 +4,7 @@ import (
"fmt"
"github.com/grafana/grafana-plugin-sdk-go/data"
influxdb2 "github.com/influxdata/influxdb-client-go"
"github.com/influxdata/influxdb-client-go/api/query"
)
// Copied from: (Apache 2 license)
......@@ -26,9 +26,9 @@ type columnInfo struct {
converter *data.FieldConverter
}
// This is an interface to help testing
// FrameBuilder This is an interface to help testing
type FrameBuilder struct {
tableId int64
tableID int64
active *data.Frame
frames []*data.Frame
value *data.FieldConverter
......@@ -72,10 +72,10 @@ func getConverter(t string) (*data.FieldConverter, error) {
// Init initializes the frame to be returned
// fields points at entries in the frame, and provides easier access
// names indexes the columns encountered
func (fb *FrameBuilder) Init(metadata *influxdb2.FluxTableMetadata) error {
func (fb *FrameBuilder) Init(metadata *query.FluxTableMetadata) error {
columns := metadata.Columns()
fb.frames = make([]*data.Frame, 0)
fb.tableId = -1
fb.tableID = -1
fb.value = nil
fb.columns = make([]columnInfo, 0)
fb.isTimeSeries = false
......@@ -120,9 +120,9 @@ func (fb *FrameBuilder) Init(metadata *influxdb2.FluxTableMetadata) error {
// Tags are appended as labels
// _measurement holds the dataframe name
// _field holds the field name.
func (fb *FrameBuilder) Append(record *influxdb2.FluxRecord) error {
func (fb *FrameBuilder) Append(record *query.FluxRecord) error {
table, ok := record.ValueByKey("table").(int64)
if ok && table != fb.tableId {
if ok && table != fb.tableID {
fb.totalSeries++
if fb.totalSeries > fb.maxSeries {
return fmt.Errorf("reached max series limit (%d)", fb.maxSeries)
......@@ -153,7 +153,7 @@ func (fb *FrameBuilder) Append(record *influxdb2.FluxRecord) error {
}
fb.frames = append(fb.frames, fb.active)
fb.tableId = table
fb.tableID = table
}
if fb.isTimeSeries {
......
......@@ -6,7 +6,7 @@ import (
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana-plugin-sdk-go/data"
influxdb2 "github.com/influxdata/influxdb-client-go"
"github.com/influxdata/influxdb-client-go/api"
)
// ExecuteQuery runs a flux query using the QueryModel to interpolate the query and the runner to execute it.
......@@ -45,7 +45,7 @@ func ExecuteQuery(ctx context.Context, query QueryModel, runner queryRunner, max
return dr
}
func readDataFrames(result *influxdb2.QueryTableResult, maxPoints int, maxSeries int) (dr backend.DataResponse) {
func readDataFrames(result *api.QueryTableResult, maxPoints int, maxSeries int) (dr backend.DataResponse) {
dr = backend.DataResponse{}
builder := &FrameBuilder{
......
......@@ -11,6 +11,7 @@ import (
"time"
influxdb2 "github.com/influxdata/influxdb-client-go"
"github.com/influxdata/influxdb-client-go/api"
)
//--------------------------------------------------------------
......@@ -22,7 +23,7 @@ type MockRunner struct {
testDataPath string
}
func (r *MockRunner) runQuery(ctx context.Context, q string) (*influxdb2.QueryTableResult, error) {
func (r *MockRunner) runQuery(ctx context.Context, q string) (*api.QueryTableResult, error) {
bytes, err := ioutil.ReadFile("./testdata/" + r.testDataPath)
if err != nil {
return nil, err
......
......@@ -9,6 +9,7 @@ import (
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/tsdb"
influxdb2 "github.com/influxdata/influxdb-client-go"
"github.com/influxdata/influxdb-client-go/api"
)
var (
......@@ -53,11 +54,11 @@ type Runner struct {
// This is an interface to help testing
type queryRunner interface {
runQuery(ctx context.Context, q string) (*influxdb2.QueryTableResult, error)
runQuery(ctx context.Context, q string) (*api.QueryTableResult, error)
}
// runQuery executes fluxQuery against the Runner's organization and returns an flux typed result.
func (r *Runner) runQuery(ctx context.Context, fluxQuery string) (*influxdb2.QueryTableResult, error) {
func (r *Runner) runQuery(ctx context.Context, fluxQuery string) (*api.QueryTableResult, error) {
return r.client.QueryApi(r.org).Query(ctx, fluxQuery)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment