@@ -51,6 +51,44 @@ func init() {
51
51
}
52
52
}
53
53
54
+ func (e * InfluxDBExecutor ) Execute (ctx context.Context , queries tsdb.QuerySlice , context * tsdb.QueryContext ) * tsdb.BatchResult {
55
+ result := & tsdb.BatchResult {}
56
+
57
+ query , err := e .getQuery (queries , context )
58
+ if err != nil {
59
+ return result .WithError (err )
60
+ }
61
+
62
+ glog .Debug ("Influxdb query" , "raw query" , query )
63
+
64
+ req , err := e .createRequest (query )
65
+ if err != nil {
66
+ return result .WithError (err )
67
+ }
68
+
69
+ resp , err := ctxhttp .Do (ctx , HttpClient , req )
70
+ if err != nil {
71
+ return result .WithError (err )
72
+ }
73
+
74
+ if resp .StatusCode / 100 != 2 {
75
+ return result .WithError (fmt .Errorf ("Influxdb returned statuscode invalid status code: %v" , resp .Status ))
76
+ }
77
+
78
+ var response Response
79
+ dec := json .NewDecoder (resp .Body )
80
+ dec .UseNumber ()
81
+ err = dec .Decode (& response )
82
+ if err != nil {
83
+ return result .WithError (err )
84
+ }
85
+
86
+ result .QueryResults = make (map [string ]* tsdb.QueryResult )
87
+ result .QueryResults ["A" ] = e .ResponseParser .Parse (& response )
88
+
89
+ return result
90
+ }
91
+
54
92
func (e * InfluxDBExecutor ) getQuery (queries tsdb.QuerySlice , context * tsdb.QueryContext ) (string , error ) {
55
93
for _ , v := range queries {
56
94
query , err := e .QueryParser .Parse (v .Model )
@@ -92,41 +130,3 @@ func (e *InfluxDBExecutor) createRequest(query string) (*http.Request, error) {
92
130
glog .Debug ("influxdb request" , "url" , req .URL .String ())
93
131
return req , nil
94
132
}
95
-
96
- func (e * InfluxDBExecutor ) Execute (ctx context.Context , queries tsdb.QuerySlice , context * tsdb.QueryContext ) * tsdb.BatchResult {
97
- result := & tsdb.BatchResult {}
98
-
99
- query , err := e .getQuery (queries , context )
100
- if err != nil {
101
- return result .WithError (err )
102
- }
103
-
104
- glog .Debug ("Influxdb query" , "raw query" , query )
105
-
106
- req , err := e .createRequest (query )
107
- if err != nil {
108
- return result .WithError (err )
109
- }
110
-
111
- resp , err := ctxhttp .Do (ctx , HttpClient , req )
112
- if err != nil {
113
- return result .WithError (err )
114
- }
115
-
116
- if resp .StatusCode / 100 != 2 {
117
- return result .WithError (fmt .Errorf ("Influxdb returned statuscode invalid status code: %v" , resp .Status ))
118
- }
119
-
120
- var response Response
121
- dec := json .NewDecoder (resp .Body )
122
- dec .UseNumber ()
123
- err = dec .Decode (& response )
124
- if err != nil {
125
- return result .WithError (err )
126
- }
127
-
128
- result .QueryResults = make (map [string ]* tsdb.QueryResult )
129
- result .QueryResults ["A" ] = e .ResponseParser .Parse (& response )
130
-
131
- return result
132
- }
0 commit comments