InfluxDB: Upgrade Go client, use data source HTTP client (#27012)

* InfluxDB: Upgrade Go client, use data source HTTP client

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Remove unnecessary Close

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
Arve Knudsen
2020-08-14 18:40:02 +02:00
committed by GitHub
parent 6609ddb082
commit 50ebbb625e
6 changed files with 34 additions and 18 deletions
-1
View File
@@ -33,7 +33,6 @@ func executeQuery(ctx context.Context, query QueryModel, runner queryRunner, max
dr.Frames = append(dr.Frames, metaFrame)
return
}
defer tables.Close()
dr = readDataFrames(tables, int(float64(query.MaxDataPoints)*1.5), maxSeries)
+1 -1
View File
@@ -47,7 +47,7 @@ func (r *MockRunner) runQuery(ctx context.Context, q string) (*api.QueryTableRes
defer server.Close()
client := influxdb2.NewClient(server.URL, "a")
return client.QueryApi("x").Query(ctx, q)
return client.QueryAPI("x").Query(ctx, q)
}
func verifyGoldenResponse(name string) (*backend.DataResponse, error) {
+8 -2
View File
@@ -60,7 +60,7 @@ type queryRunner interface {
// runQuery executes fluxQuery against the Runner's organization and returns a Flux typed result.
func (r *Runner) runQuery(ctx context.Context, fluxQuery string) (*api.QueryTableResult, error) {
qa := r.client.QueryApi(r.org)
qa := r.client.QueryAPI(r.org)
return qa.Query(ctx, fluxQuery)
}
@@ -80,8 +80,14 @@ func RunnerFromDataSource(dsInfo *models.DataSource) (*Runner, error) {
return nil, fmt.Errorf("token is missing from datasource configuration and is needed to use Flux")
}
opts := influxdb2.DefaultOptions()
hc, err := dsInfo.GetHttpClient()
if err != nil {
return nil, err
}
opts.HTTPOptions().SetHTTPClient(hc)
return &Runner{
client: influxdb2.NewClient(url, token),
client: influxdb2.NewClientWithOptions(url, token, opts),
org: org,
}, nil
}
-1
View File
@@ -21,7 +21,6 @@ type InfluxDBExecutor struct {
//*models.DataSource
QueryParser *InfluxdbQueryParser
ResponseParser *ResponseParser
//HttpClient *http.Client
}
func NewInfluxDBExecutor(datasource *models.DataSource) (tsdb.TsdbQueryEndpoint, error) {