Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
7f9f3882
Commit
7f9f3882
authored
Sep 21, 2017
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename executor into tsdbqueryendpoint
parent
0229d28d
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
29 additions
and
29 deletions
+29
-29
pkg/tsdb/batch.go
+2
-2
pkg/tsdb/fake_test.go
+1
-1
pkg/tsdb/graphite/graphite.go
+3
-3
pkg/tsdb/influxdb/influxdb.go
+3
-3
pkg/tsdb/mysql/mysql.go
+3
-3
pkg/tsdb/opentsdb/opentsdb.go
+3
-3
pkg/tsdb/prometheus/prometheus.go
+3
-3
pkg/tsdb/query_endpoint.go
+7
-7
pkg/tsdb/testdata/testdata.go
+3
-3
pkg/tsdb/tsdb_test.go
+1
-1
No files found.
pkg/tsdb/batch.go
View file @
7f9f3882
...
...
@@ -21,7 +21,7 @@ func newBatch(dsId int64, queries []*Query) *Batch {
}
func
(
bg
*
Batch
)
process
(
ctx
context
.
Context
,
resultChan
chan
*
BatchResult
,
tsdbQuery
*
TsdbQuery
)
{
executor
,
err
:=
get
Executor
For
(
bg
.
Queries
[
0
]
.
DataSource
)
executor
,
err
:=
get
TsdbQueryEndpoint
For
(
bg
.
Queries
[
0
]
.
DataSource
)
if
err
!=
nil
{
bg
.
Done
=
true
...
...
@@ -36,7 +36,7 @@ func (bg *Batch) process(ctx context.Context, resultChan chan *BatchResult, tsdb
return
}
res
:=
executor
.
Execute
(
ctx
,
&
TsdbQuery
{
res
:=
executor
.
Query
(
ctx
,
&
TsdbQuery
{
Queries
:
bg
.
Queries
,
TimeRange
:
tsdbQuery
.
TimeRange
,
})
...
...
pkg/tsdb/fake_test.go
View file @
7f9f3882
...
...
@@ -20,7 +20,7 @@ func NewFakeExecutor(dsInfo *models.DataSource) (*FakeExecutor, error) {
},
nil
}
func
(
e
*
FakeExecutor
)
Execute
(
ctx
context
.
Context
,
context
*
TsdbQuery
)
*
BatchResult
{
func
(
e
*
FakeExecutor
)
Query
(
ctx
context
.
Context
,
context
*
TsdbQuery
)
*
BatchResult
{
result
:=
&
BatchResult
{
QueryResults
:
make
(
map
[
string
]
*
QueryResult
)}
for
_
,
query
:=
range
context
.
Queries
{
if
results
,
has
:=
e
.
results
[
query
.
RefId
];
has
{
...
...
pkg/tsdb/graphite/graphite.go
View file @
7f9f3882
...
...
@@ -25,7 +25,7 @@ type GraphiteExecutor struct {
HttpClient
*
http
.
Client
}
func
NewGraphiteExecutor
(
datasource
*
models
.
DataSource
)
(
tsdb
.
Executor
,
error
)
{
func
NewGraphiteExecutor
(
datasource
*
models
.
DataSource
)
(
tsdb
.
TsdbQueryEndpoint
,
error
)
{
httpClient
,
err
:=
datasource
.
GetHttpClient
()
if
err
!=
nil
{
...
...
@@ -44,10 +44,10 @@ var (
func
init
()
{
glog
=
log
.
New
(
"tsdb.graphite"
)
tsdb
.
Register
Executor
(
"graphite"
,
NewGraphiteExecutor
)
tsdb
.
Register
TsdbQueryEndpoint
(
"graphite"
,
NewGraphiteExecutor
)
}
func
(
e
*
GraphiteExecutor
)
Execute
(
ctx
context
.
Context
,
context
*
tsdb
.
TsdbQuery
)
*
tsdb
.
BatchResult
{
func
(
e
*
GraphiteExecutor
)
Query
(
ctx
context
.
Context
,
context
*
tsdb
.
TsdbQuery
)
*
tsdb
.
BatchResult
{
result
:=
&
tsdb
.
BatchResult
{}
from
:=
"-"
+
formatTimeRange
(
context
.
TimeRange
.
From
)
...
...
pkg/tsdb/influxdb/influxdb.go
View file @
7f9f3882
...
...
@@ -23,7 +23,7 @@ type InfluxDBExecutor struct {
HttpClient
*
http
.
Client
}
func
NewInfluxDBExecutor
(
datasource
*
models
.
DataSource
)
(
tsdb
.
Executor
,
error
)
{
func
NewInfluxDBExecutor
(
datasource
*
models
.
DataSource
)
(
tsdb
.
TsdbQueryEndpoint
,
error
)
{
httpClient
,
err
:=
datasource
.
GetHttpClient
()
if
err
!=
nil
{
...
...
@@ -44,10 +44,10 @@ var (
func
init
()
{
glog
=
log
.
New
(
"tsdb.influxdb"
)
tsdb
.
Register
Executor
(
"influxdb"
,
NewInfluxDBExecutor
)
tsdb
.
Register
TsdbQueryEndpoint
(
"influxdb"
,
NewInfluxDBExecutor
)
}
func
(
e
*
InfluxDBExecutor
)
Execute
(
ctx
context
.
Context
,
context
*
tsdb
.
TsdbQuery
)
*
tsdb
.
BatchResult
{
func
(
e
*
InfluxDBExecutor
)
Query
(
ctx
context
.
Context
,
context
*
tsdb
.
TsdbQuery
)
*
tsdb
.
BatchResult
{
result
:=
&
tsdb
.
BatchResult
{}
query
,
err
:=
e
.
getQuery
(
context
.
Queries
,
context
)
...
...
pkg/tsdb/mysql/mysql.go
View file @
7f9f3882
...
...
@@ -38,10 +38,10 @@ var engineCache = engineCacheType{
}
func
init
()
{
tsdb
.
Register
Executor
(
"mysql"
,
NewMysqlExecutor
)
tsdb
.
Register
TsdbQueryEndpoint
(
"mysql"
,
NewMysqlExecutor
)
}
func
NewMysqlExecutor
(
datasource
*
models
.
DataSource
)
(
tsdb
.
Executor
,
error
)
{
func
NewMysqlExecutor
(
datasource
*
models
.
DataSource
)
(
tsdb
.
TsdbQueryEndpoint
,
error
)
{
executor
:=
&
MysqlExecutor
{
datasource
:
datasource
,
log
:
log
.
New
(
"tsdb.mysql"
),
...
...
@@ -81,7 +81,7 @@ func (e *MysqlExecutor) initEngine() error {
return
nil
}
func
(
e
*
MysqlExecutor
)
Execute
(
ctx
context
.
Context
,
context
*
tsdb
.
TsdbQuery
)
*
tsdb
.
BatchResult
{
func
(
e
*
MysqlExecutor
)
Query
(
ctx
context
.
Context
,
context
*
tsdb
.
TsdbQuery
)
*
tsdb
.
BatchResult
{
result
:=
&
tsdb
.
BatchResult
{
QueryResults
:
make
(
map
[
string
]
*
tsdb
.
QueryResult
),
}
...
...
pkg/tsdb/opentsdb/opentsdb.go
View file @
7f9f3882
...
...
@@ -26,7 +26,7 @@ type OpenTsdbExecutor struct {
httpClient
*
http
.
Client
}
func
NewOpenTsdbExecutor
(
datasource
*
models
.
DataSource
)
(
tsdb
.
Executor
,
error
)
{
func
NewOpenTsdbExecutor
(
datasource
*
models
.
DataSource
)
(
tsdb
.
TsdbQueryEndpoint
,
error
)
{
httpClient
,
err
:=
datasource
.
GetHttpClient
()
if
err
!=
nil
{
...
...
@@ -45,10 +45,10 @@ var (
func
init
()
{
plog
=
log
.
New
(
"tsdb.opentsdb"
)
tsdb
.
Register
Executor
(
"opentsdb"
,
NewOpenTsdbExecutor
)
tsdb
.
Register
TsdbQueryEndpoint
(
"opentsdb"
,
NewOpenTsdbExecutor
)
}
func
(
e
*
OpenTsdbExecutor
)
Execute
(
ctx
context
.
Context
,
queryContext
*
tsdb
.
TsdbQuery
)
*
tsdb
.
BatchResult
{
func
(
e
*
OpenTsdbExecutor
)
Query
(
ctx
context
.
Context
,
queryContext
*
tsdb
.
TsdbQuery
)
*
tsdb
.
BatchResult
{
result
:=
&
tsdb
.
BatchResult
{}
var
tsdbQuery
OpenTsdbQuery
...
...
pkg/tsdb/prometheus/prometheus.go
View file @
7f9f3882
...
...
@@ -39,7 +39,7 @@ func (bat basicAuthTransport) RoundTrip(req *http.Request) (*http.Response, erro
return
bat
.
Transport
.
RoundTrip
(
req
)
}
func
NewPrometheusExecutor
(
dsInfo
*
models
.
DataSource
)
(
tsdb
.
Executor
,
error
)
{
func
NewPrometheusExecutor
(
dsInfo
*
models
.
DataSource
)
(
tsdb
.
TsdbQueryEndpoint
,
error
)
{
transport
,
err
:=
dsInfo
.
GetHttpTransport
()
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -58,7 +58,7 @@ var (
func
init
()
{
plog
=
log
.
New
(
"tsdb.prometheus"
)
tsdb
.
Register
Executor
(
"prometheus"
,
NewPrometheusExecutor
)
tsdb
.
Register
TsdbQueryEndpoint
(
"prometheus"
,
NewPrometheusExecutor
)
legendFormat
=
regexp
.
MustCompile
(
`\{\{\s*(.+?)\s*\}\}`
)
}
...
...
@@ -84,7 +84,7 @@ func (e *PrometheusExecutor) getClient() (apiv1.API, error) {
return
apiv1
.
NewAPI
(
client
),
nil
}
func
(
e
*
PrometheusExecutor
)
Execute
(
ctx
context
.
Context
,
queryContext
*
tsdb
.
TsdbQuery
)
*
tsdb
.
BatchResult
{
func
(
e
*
PrometheusExecutor
)
Query
(
ctx
context
.
Context
,
queryContext
*
tsdb
.
TsdbQuery
)
*
tsdb
.
BatchResult
{
result
:=
&
tsdb
.
BatchResult
{}
client
,
err
:=
e
.
getClient
()
...
...
pkg/tsdb/
executor
.go
→
pkg/tsdb/
query_endpoint
.go
View file @
7f9f3882
...
...
@@ -7,19 +7,19 @@ import (
"github.com/grafana/grafana/pkg/models"
)
type
Executor
interface
{
Execute
(
ctx
context
.
Context
,
query
*
TsdbQuery
)
*
BatchResult
type
TsdbQueryEndpoint
interface
{
Query
(
ctx
context
.
Context
,
query
*
TsdbQuery
)
*
BatchResult
}
var
registry
map
[
string
]
Get
Executor
Fn
var
registry
map
[
string
]
Get
TsdbQueryEndpoint
Fn
type
Get
ExecutorFn
func
(
dsInfo
*
models
.
DataSource
)
(
Executor
,
error
)
type
Get
TsdbQueryEndpointFn
func
(
dsInfo
*
models
.
DataSource
)
(
TsdbQueryEndpoint
,
error
)
func
init
()
{
registry
=
make
(
map
[
string
]
Get
Executor
Fn
)
registry
=
make
(
map
[
string
]
Get
TsdbQueryEndpoint
Fn
)
}
func
get
ExecutorFor
(
dsInfo
*
models
.
DataSource
)
(
Executor
,
error
)
{
func
get
TsdbQueryEndpointFor
(
dsInfo
*
models
.
DataSource
)
(
TsdbQueryEndpoint
,
error
)
{
if
fn
,
exists
:=
registry
[
dsInfo
.
Type
];
exists
{
executor
,
err
:=
fn
(
dsInfo
)
if
err
!=
nil
{
...
...
@@ -31,6 +31,6 @@ func getExecutorFor(dsInfo *models.DataSource) (Executor, error) {
return
nil
,
fmt
.
Errorf
(
"Could not find executor for data source type: %s"
,
dsInfo
.
Type
)
}
func
Register
Executor
(
pluginId
string
,
fn
GetExecutor
Fn
)
{
func
Register
TsdbQueryEndpoint
(
pluginId
string
,
fn
GetTsdbQueryEndpoint
Fn
)
{
registry
[
pluginId
]
=
fn
}
pkg/tsdb/testdata/testdata.go
View file @
7f9f3882
...
...
@@ -13,7 +13,7 @@ type TestDataExecutor struct {
log
log
.
Logger
}
func
NewTestDataExecutor
(
dsInfo
*
models
.
DataSource
)
(
tsdb
.
Executor
,
error
)
{
func
NewTestDataExecutor
(
dsInfo
*
models
.
DataSource
)
(
tsdb
.
TsdbQueryEndpoint
,
error
)
{
return
&
TestDataExecutor
{
DataSource
:
dsInfo
,
log
:
log
.
New
(
"tsdb.testdata"
),
...
...
@@ -21,10 +21,10 @@ func NewTestDataExecutor(dsInfo *models.DataSource) (tsdb.Executor, error) {
}
func
init
()
{
tsdb
.
Register
Executor
(
"grafana-testdata-datasource"
,
NewTestDataExecutor
)
tsdb
.
Register
TsdbQueryEndpoint
(
"grafana-testdata-datasource"
,
NewTestDataExecutor
)
}
func
(
e
*
TestDataExecutor
)
Execute
(
ctx
context
.
Context
,
context
*
tsdb
.
TsdbQuery
)
*
tsdb
.
BatchResult
{
func
(
e
*
TestDataExecutor
)
Query
(
ctx
context
.
Context
,
context
*
tsdb
.
TsdbQuery
)
*
tsdb
.
BatchResult
{
result
:=
&
tsdb
.
BatchResult
{}
result
.
QueryResults
=
make
(
map
[
string
]
*
tsdb
.
QueryResult
)
...
...
pkg/tsdb/tsdb_test.go
View file @
7f9f3882
...
...
@@ -169,7 +169,7 @@ func TestMetricQuery(t *testing.T) {
func
registerFakeExecutor
()
*
FakeExecutor
{
executor
,
_
:=
NewFakeExecutor
(
nil
)
Register
Executor
(
"test"
,
func
(
dsInfo
*
models
.
DataSource
)
(
Executor
,
error
)
{
Register
TsdbQueryEndpoint
(
"test"
,
func
(
dsInfo
*
models
.
DataSource
)
(
TsdbQueryEndpoint
,
error
)
{
return
executor
,
nil
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment