Update query interface to take database and rp
parent
92225fdc49
commit
1d4d3668d8
|
@ -34,7 +34,17 @@ func NewClient(host string) (*Client, error) {
|
||||||
// include both the database and retention policy. In-flight requests can be
|
// include both the database and retention policy. In-flight requests can be
|
||||||
// cancelled using the provided context.
|
// cancelled using the provided context.
|
||||||
func (c *Client) Query(ctx context.Context, query mrfusion.Query) (mrfusion.Response, error) {
|
func (c *Client) Query(ctx context.Context, query mrfusion.Query) (mrfusion.Response, error) {
|
||||||
q := ixClient.NewQuery(string(query), "", "")
|
db := ""
|
||||||
|
if len(query.Database) > 0 {
|
||||||
|
db = query.Database
|
||||||
|
}
|
||||||
|
|
||||||
|
rp := ""
|
||||||
|
if len(query.RP) > 0 {
|
||||||
|
rp = query.RP
|
||||||
|
}
|
||||||
|
|
||||||
|
q := ixClient.NewQuery(query.Command, db, rp)
|
||||||
resps := make(chan (response))
|
resps := make(chan (response))
|
||||||
go func() {
|
go func() {
|
||||||
resp, err := c.ix.Query(q)
|
resp, err := c.ix.Query(q)
|
||||||
|
|
|
@ -57,8 +57,12 @@ func (m *Handler) SourcesID(ctx context.Context, params op.GetSourcesIDParams) m
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Handler) Proxy(ctx context.Context, params op.PostSourcesIDProxyParams) middleware.Responder {
|
func (m *Handler) Proxy(ctx context.Context, params op.PostSourcesIDProxyParams) middleware.Responder {
|
||||||
query := params.Query.Query
|
query := mrfusion.Query{
|
||||||
response, err := m.TimeSeries.Query(ctx, mrfusion.Query(*query))
|
Command: *params.Query.Query,
|
||||||
|
Database: params.Query.Database,
|
||||||
|
RP: params.Query.Rp,
|
||||||
|
}
|
||||||
|
response, err := m.TimeSeries.Query(ctx, mrfusion.Query(query))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return op.NewPostSourcesIDProxyDefault(500)
|
return op.NewPostSourcesIDProxyDefault(500)
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,10 @@ swagger:model Proxy
|
||||||
*/
|
*/
|
||||||
type Proxy struct {
|
type Proxy struct {
|
||||||
|
|
||||||
|
/* database
|
||||||
|
*/
|
||||||
|
Database string `json:"database,omitempty"`
|
||||||
|
|
||||||
/* format
|
/* format
|
||||||
*/
|
*/
|
||||||
Format *string `json:"format,omitempty"`
|
Format *string `json:"format,omitempty"`
|
||||||
|
@ -28,6 +32,10 @@ type Proxy struct {
|
||||||
Required: true
|
Required: true
|
||||||
*/
|
*/
|
||||||
Query *string `json:"query"`
|
Query *string `json:"query"`
|
||||||
|
|
||||||
|
/* rp
|
||||||
|
*/
|
||||||
|
Rp string `json:"rp,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate validates this proxy
|
// Validate validates this proxy
|
||||||
|
|
|
@ -788,6 +788,10 @@ definitions:
|
||||||
properties:
|
properties:
|
||||||
query:
|
query:
|
||||||
type: string
|
type: string
|
||||||
|
database:
|
||||||
|
type: string
|
||||||
|
rp:
|
||||||
|
type: string
|
||||||
format:
|
format:
|
||||||
type: string
|
type: string
|
||||||
enum:
|
enum:
|
||||||
|
|
|
@ -6,8 +6,12 @@ import (
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Used to retrieve a Response from a TimeSeries.
|
// Query retrieves a Response from a TimeSeries.
|
||||||
type Query string
|
type Query struct {
|
||||||
|
Command string // Command is the query itself
|
||||||
|
Database string // Database is optional and if empty will not be used.
|
||||||
|
RP string // RP is a retention policy and optional; if empty will not be used.
|
||||||
|
}
|
||||||
|
|
||||||
// Row represents a single row returned from the execution of a single statement in a `Query`.
|
// Row represents a single row returned from the execution of a single statement in a `Query`.
|
||||||
type Row interface {
|
type Row interface {
|
||||||
|
|
Loading…
Reference in New Issue