Skip to content

Commit

Permalink
make InfluxDB client pluggable (influxdata#769)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathaniel Cook authored Aug 2, 2016
1 parent 9c01f78 commit 14a8e49
Show file tree
Hide file tree
Showing 14 changed files with 956 additions and 91 deletions.
6 changes: 3 additions & 3 deletions batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"time"

"github.com/gorhill/cronexpr"
client "github.com/influxdata/influxdb/client/v2"
"github.com/influxdata/influxdb/influxql"
"github.com/influxdata/kapacitor/expvar"
"github.com/influxdata/kapacitor/influxdb"
"github.com/influxdata/kapacitor/models"
"github.com/influxdata/kapacitor/pipeline"
)
Expand Down Expand Up @@ -269,7 +269,7 @@ func (b *QueryNode) doQuery() error {
return errors.New("InfluxDB not configured, cannot query InfluxDB for batch query")
}

var con client.Client
var con influxdb.Client
tickC := b.ticker.Start()
for {
select {
Expand Down Expand Up @@ -303,7 +303,7 @@ func (b *QueryNode) doQuery() error {
break
}
}
q := client.Query{
q := influxdb.Query{
Command: b.query.String(),
}

Expand Down
11 changes: 11 additions & 0 deletions client/v1/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,7 @@ func (c *Client) CreateTask(opt CreateTaskOptions) (Task, error) {
if err != nil {
return Task{}, err
}
req.Header.Set("Content-Type", "application/json")

t := Task{}
_, err = c.Do(req, &t, http.StatusOK)
Expand Down Expand Up @@ -752,6 +753,7 @@ func (c *Client) UpdateTask(link Link, opt UpdateTaskOptions) (Task, error) {
if err != nil {
return t, err
}
req.Header.Set("Content-Type", "application/json")

_, err = c.Do(req, &t, http.StatusOK)
if err != nil {
Expand Down Expand Up @@ -927,6 +929,7 @@ func (c *Client) CreateTemplate(opt CreateTemplateOptions) (Template, error) {
if err != nil {
return Template{}, err
}
req.Header.Set("Content-Type", "application/json")

t := Template{}
_, err = c.Do(req, &t, http.StatusOK)
Expand Down Expand Up @@ -961,6 +964,7 @@ func (c *Client) UpdateTemplate(link Link, opt UpdateTemplateOptions) (Template,
if err != nil {
return t, err
}
req.Header.Set("Content-Type", "application/json")

_, err = c.Do(req, &t, http.StatusOK)
if err != nil {
Expand Down Expand Up @@ -1140,6 +1144,7 @@ func (c *Client) RecordStream(opt RecordStreamOptions) (Recording, error) {
if err != nil {
return r, err
}
req.Header.Set("Content-Type", "application/json")

_, err = c.Do(req, &r, http.StatusCreated)
if err != nil {
Expand Down Expand Up @@ -1174,6 +1179,7 @@ func (c *Client) RecordBatch(opt RecordBatchOptions) (Recording, error) {
if err != nil {
return r, err
}
req.Header.Set("Content-Type", "application/json")

_, err = c.Do(req, &r, http.StatusCreated)
if err != nil {
Expand Down Expand Up @@ -1209,6 +1215,7 @@ func (c *Client) RecordQuery(opt RecordQueryOptions) (Recording, error) {
if err != nil {
return r, err
}
req.Header.Set("Content-Type", "application/json")

_, err = c.Do(req, &r, http.StatusCreated)
if err != nil {
Expand Down Expand Up @@ -1322,6 +1329,7 @@ func (c *Client) CreateReplay(opt CreateReplayOptions) (Replay, error) {
if err != nil {
return r, err
}
req.Header.Set("Content-Type", "application/json")

_, err = c.Do(req, &r, http.StatusCreated)
if err != nil {
Expand Down Expand Up @@ -1357,6 +1365,7 @@ func (c *Client) ReplayBatch(opt ReplayBatchOptions) (Replay, error) {
if err != nil {
return r, err
}
req.Header.Set("Content-Type", "application/json")

_, err = c.Do(req, &r, http.StatusCreated)
if err != nil {
Expand Down Expand Up @@ -1392,6 +1401,7 @@ func (c *Client) ReplayQuery(opt ReplayQueryOptions) (Replay, error) {
if err != nil {
return r, err
}
req.Header.Set("Content-Type", "application/json")

_, err = c.Do(req, &r, http.StatusCreated)
if err != nil {
Expand Down Expand Up @@ -1517,6 +1527,7 @@ func (c *Client) LogLevel(level string) error {
if err != nil {
return err
}
req.Header.Set("Content-Type", "application/json")

_, err = c.Do(req, nil, http.StatusNoContent)
return err
Expand Down
Loading

0 comments on commit 14a8e49

Please sign in to comment.