influxdb/source/query.go

44 lines
1.7 KiB
Go
Raw Normal View History

feat(platform): add uniform query endpoint for sources Using query request struct to query resources Signed-off-by: Lorenzo Fontana <lo@linux.com> Use query.ProxyRequest instead query.Request Signed-off-by: Lorenzo Fontana <lo@linux.com> Proxy request from idpd Signed-off-by: Lorenzo Fontana <lo@linux.com> Comments about the desired results Signed-off-by: Lorenzo Fontana <lo@linux.com> V1 endpoints working with flux Signed-off-by: Lorenzo Fontana <lo@linux.com> Influxql working for v1 Signed-off-by: Lorenzo Fontana <lo@linux.com> Co-authored-by: Michael De Sa <mjdesa@gmail.com> V2 influxql query endpoint working Signed-off-by: Lorenzo Fontana <lo@linux.com> Co-authored-by: Michael De Sa <mjdesa@gmail.com> Signed-off-by: Lorenzo Fontana <lo@linux.com> V2 Flux compiler support Co-authored-by: Michael De Sa <mjdesa@gmail.com> Signed-off-by: Lorenzo Fontana <lo@linux.com> Improve comments in bolt sources and give error on self Signed-off-by: Lorenzo Fontana <lo@linux.com> Co-authored-by: Michael De Sa <mjdesa@gmail.com> Review tests failing Signed-off-by: Lorenzo Fontana <lo@linux.com> Co-authored-by: Michael De Sa <mjdesa@gmail.com> Avoid type casts for compiler types Signed-off-by: Lorenzo Fontana <lo@linux.com> Co-authored-by: Michael De Sa <mjdesa@gmail.com> Using nil instead of dbrp mapping service for influxql v1 Signed-off-by: Lorenzo Fontana <lo@linux.com> Check if compiler types are valid for influxql Signed-off-by: Lorenzo Fontana <lo@linux.com> Organization as query param in the flux external handler Signed-off-by: Lorenzo Fontana <lo@linux.com> feat(http): update swagger documentation for flux query endpoint feat(http): document query endpoint design The code documented does not currently work. It is indended that this will be implemented in follow up PRs. feat(platform): move source to platform package The source Query endpoint implements what's in the query swagger docs Signed-off-by: Lorenzo Fontana <lo@linux.com> Co-authored-by: Michael De Sa <mjdesa@gmail.com> feat(platform): allow for encoding and decoding of csv dialects feat(platform): specify dialect in flux page Co-authored-by: Andrew Watkins <andrew.watkinz@gmail.com> Co-authored-by: Michael Desa <mjdesa@gmail.com>
2018-08-28 19:53:20 +00:00
package source
import (
"fmt"
"github.com/influxdata/platform"
"github.com/influxdata/platform/http"
"github.com/influxdata/platform/http/influxdb"
"github.com/influxdata/platform/query"
feat(platform): add uniform query endpoint for sources Using query request struct to query resources Signed-off-by: Lorenzo Fontana <lo@linux.com> Use query.ProxyRequest instead query.Request Signed-off-by: Lorenzo Fontana <lo@linux.com> Proxy request from idpd Signed-off-by: Lorenzo Fontana <lo@linux.com> Comments about the desired results Signed-off-by: Lorenzo Fontana <lo@linux.com> V1 endpoints working with flux Signed-off-by: Lorenzo Fontana <lo@linux.com> Influxql working for v1 Signed-off-by: Lorenzo Fontana <lo@linux.com> Co-authored-by: Michael De Sa <mjdesa@gmail.com> V2 influxql query endpoint working Signed-off-by: Lorenzo Fontana <lo@linux.com> Co-authored-by: Michael De Sa <mjdesa@gmail.com> Signed-off-by: Lorenzo Fontana <lo@linux.com> V2 Flux compiler support Co-authored-by: Michael De Sa <mjdesa@gmail.com> Signed-off-by: Lorenzo Fontana <lo@linux.com> Improve comments in bolt sources and give error on self Signed-off-by: Lorenzo Fontana <lo@linux.com> Co-authored-by: Michael De Sa <mjdesa@gmail.com> Review tests failing Signed-off-by: Lorenzo Fontana <lo@linux.com> Co-authored-by: Michael De Sa <mjdesa@gmail.com> Avoid type casts for compiler types Signed-off-by: Lorenzo Fontana <lo@linux.com> Co-authored-by: Michael De Sa <mjdesa@gmail.com> Using nil instead of dbrp mapping service for influxql v1 Signed-off-by: Lorenzo Fontana <lo@linux.com> Check if compiler types are valid for influxql Signed-off-by: Lorenzo Fontana <lo@linux.com> Organization as query param in the flux external handler Signed-off-by: Lorenzo Fontana <lo@linux.com> feat(http): update swagger documentation for flux query endpoint feat(http): document query endpoint design The code documented does not currently work. It is indended that this will be implemented in follow up PRs. feat(platform): move source to platform package The source Query endpoint implements what's in the query swagger docs Signed-off-by: Lorenzo Fontana <lo@linux.com> Co-authored-by: Michael De Sa <mjdesa@gmail.com> feat(platform): allow for encoding and decoding of csv dialects feat(platform): specify dialect in flux page Co-authored-by: Andrew Watkins <andrew.watkinz@gmail.com> Co-authored-by: Michael Desa <mjdesa@gmail.com>
2018-08-28 19:53:20 +00:00
)
// NewQueryService creates a bucket service from a source.
func NewQueryService(s *platform.Source) (query.ProxyQueryService, error) {
feat(platform): add uniform query endpoint for sources Using query request struct to query resources Signed-off-by: Lorenzo Fontana <lo@linux.com> Use query.ProxyRequest instead query.Request Signed-off-by: Lorenzo Fontana <lo@linux.com> Proxy request from idpd Signed-off-by: Lorenzo Fontana <lo@linux.com> Comments about the desired results Signed-off-by: Lorenzo Fontana <lo@linux.com> V1 endpoints working with flux Signed-off-by: Lorenzo Fontana <lo@linux.com> Influxql working for v1 Signed-off-by: Lorenzo Fontana <lo@linux.com> Co-authored-by: Michael De Sa <mjdesa@gmail.com> V2 influxql query endpoint working Signed-off-by: Lorenzo Fontana <lo@linux.com> Co-authored-by: Michael De Sa <mjdesa@gmail.com> Signed-off-by: Lorenzo Fontana <lo@linux.com> V2 Flux compiler support Co-authored-by: Michael De Sa <mjdesa@gmail.com> Signed-off-by: Lorenzo Fontana <lo@linux.com> Improve comments in bolt sources and give error on self Signed-off-by: Lorenzo Fontana <lo@linux.com> Co-authored-by: Michael De Sa <mjdesa@gmail.com> Review tests failing Signed-off-by: Lorenzo Fontana <lo@linux.com> Co-authored-by: Michael De Sa <mjdesa@gmail.com> Avoid type casts for compiler types Signed-off-by: Lorenzo Fontana <lo@linux.com> Co-authored-by: Michael De Sa <mjdesa@gmail.com> Using nil instead of dbrp mapping service for influxql v1 Signed-off-by: Lorenzo Fontana <lo@linux.com> Check if compiler types are valid for influxql Signed-off-by: Lorenzo Fontana <lo@linux.com> Organization as query param in the flux external handler Signed-off-by: Lorenzo Fontana <lo@linux.com> feat(http): update swagger documentation for flux query endpoint feat(http): document query endpoint design The code documented does not currently work. It is indended that this will be implemented in follow up PRs. feat(platform): move source to platform package The source Query endpoint implements what's in the query swagger docs Signed-off-by: Lorenzo Fontana <lo@linux.com> Co-authored-by: Michael De Sa <mjdesa@gmail.com> feat(platform): allow for encoding and decoding of csv dialects feat(platform): specify dialect in flux page Co-authored-by: Andrew Watkins <andrew.watkinz@gmail.com> Co-authored-by: Michael Desa <mjdesa@gmail.com>
2018-08-28 19:53:20 +00:00
switch s.Type {
case platform.SelfSourceType:
// TODO(fntlnz): this is supposed to call a query service directly locally,
// we are letting it err for now since we have some refactoring to do on
// how services are instantiated
return nil, fmt.Errorf("self source type not implemented")
case platform.V2SourceType:
// This is an influxd that calls another influxd, the query path is /v1/query - in future /v2/query
// it basically is the same as Self but on an external influxd.
feat(platform): add uniform query endpoint for sources Using query request struct to query resources Signed-off-by: Lorenzo Fontana <lo@linux.com> Use query.ProxyRequest instead query.Request Signed-off-by: Lorenzo Fontana <lo@linux.com> Proxy request from idpd Signed-off-by: Lorenzo Fontana <lo@linux.com> Comments about the desired results Signed-off-by: Lorenzo Fontana <lo@linux.com> V1 endpoints working with flux Signed-off-by: Lorenzo Fontana <lo@linux.com> Influxql working for v1 Signed-off-by: Lorenzo Fontana <lo@linux.com> Co-authored-by: Michael De Sa <mjdesa@gmail.com> V2 influxql query endpoint working Signed-off-by: Lorenzo Fontana <lo@linux.com> Co-authored-by: Michael De Sa <mjdesa@gmail.com> Signed-off-by: Lorenzo Fontana <lo@linux.com> V2 Flux compiler support Co-authored-by: Michael De Sa <mjdesa@gmail.com> Signed-off-by: Lorenzo Fontana <lo@linux.com> Improve comments in bolt sources and give error on self Signed-off-by: Lorenzo Fontana <lo@linux.com> Co-authored-by: Michael De Sa <mjdesa@gmail.com> Review tests failing Signed-off-by: Lorenzo Fontana <lo@linux.com> Co-authored-by: Michael De Sa <mjdesa@gmail.com> Avoid type casts for compiler types Signed-off-by: Lorenzo Fontana <lo@linux.com> Co-authored-by: Michael De Sa <mjdesa@gmail.com> Using nil instead of dbrp mapping service for influxql v1 Signed-off-by: Lorenzo Fontana <lo@linux.com> Check if compiler types are valid for influxql Signed-off-by: Lorenzo Fontana <lo@linux.com> Organization as query param in the flux external handler Signed-off-by: Lorenzo Fontana <lo@linux.com> feat(http): update swagger documentation for flux query endpoint feat(http): document query endpoint design The code documented does not currently work. It is indended that this will be implemented in follow up PRs. feat(platform): move source to platform package The source Query endpoint implements what's in the query swagger docs Signed-off-by: Lorenzo Fontana <lo@linux.com> Co-authored-by: Michael De Sa <mjdesa@gmail.com> feat(platform): allow for encoding and decoding of csv dialects feat(platform): specify dialect in flux page Co-authored-by: Andrew Watkins <andrew.watkinz@gmail.com> Co-authored-by: Michael Desa <mjdesa@gmail.com>
2018-08-28 19:53:20 +00:00
return &http.SourceProxyQueryService{
InsecureSkipVerify: s.InsecureSkipVerify,
Addr: s.URL,
feat(platform): add uniform query endpoint for sources Using query request struct to query resources Signed-off-by: Lorenzo Fontana <lo@linux.com> Use query.ProxyRequest instead query.Request Signed-off-by: Lorenzo Fontana <lo@linux.com> Proxy request from idpd Signed-off-by: Lorenzo Fontana <lo@linux.com> Comments about the desired results Signed-off-by: Lorenzo Fontana <lo@linux.com> V1 endpoints working with flux Signed-off-by: Lorenzo Fontana <lo@linux.com> Influxql working for v1 Signed-off-by: Lorenzo Fontana <lo@linux.com> Co-authored-by: Michael De Sa <mjdesa@gmail.com> V2 influxql query endpoint working Signed-off-by: Lorenzo Fontana <lo@linux.com> Co-authored-by: Michael De Sa <mjdesa@gmail.com> Signed-off-by: Lorenzo Fontana <lo@linux.com> V2 Flux compiler support Co-authored-by: Michael De Sa <mjdesa@gmail.com> Signed-off-by: Lorenzo Fontana <lo@linux.com> Improve comments in bolt sources and give error on self Signed-off-by: Lorenzo Fontana <lo@linux.com> Co-authored-by: Michael De Sa <mjdesa@gmail.com> Review tests failing Signed-off-by: Lorenzo Fontana <lo@linux.com> Co-authored-by: Michael De Sa <mjdesa@gmail.com> Avoid type casts for compiler types Signed-off-by: Lorenzo Fontana <lo@linux.com> Co-authored-by: Michael De Sa <mjdesa@gmail.com> Using nil instead of dbrp mapping service for influxql v1 Signed-off-by: Lorenzo Fontana <lo@linux.com> Check if compiler types are valid for influxql Signed-off-by: Lorenzo Fontana <lo@linux.com> Organization as query param in the flux external handler Signed-off-by: Lorenzo Fontana <lo@linux.com> feat(http): update swagger documentation for flux query endpoint feat(http): document query endpoint design The code documented does not currently work. It is indended that this will be implemented in follow up PRs. feat(platform): move source to platform package The source Query endpoint implements what's in the query swagger docs Signed-off-by: Lorenzo Fontana <lo@linux.com> Co-authored-by: Michael De Sa <mjdesa@gmail.com> feat(platform): allow for encoding and decoding of csv dialects feat(platform): specify dialect in flux page Co-authored-by: Andrew Watkins <andrew.watkinz@gmail.com> Co-authored-by: Michael Desa <mjdesa@gmail.com>
2018-08-28 19:53:20 +00:00
SourceFields: s.SourceFields,
}, nil
case platform.V1SourceType:
// This can be an influxdb or an influxdb + fluxd.
// If it is an influxdb alone it is just a source configured with the url of an influxdb
// and will only accept "influxql" compilers, if it has a fluxd it will also accept "flux" compilers.
// If the compiler used is "influxql" the proxy request will be made on the platform.URL directly.
// If the compiler used is "flux" the proxy request will be made on the platform.V1SourceFields.FluxURL
return &influxdb.SourceProxyQueryService{
InsecureSkipVerify: s.InsecureSkipVerify,
URL: s.URL,
SourceFields: s.SourceFields,
V1SourceFields: s.V1SourceFields,
OrganizationID: s.OrganizationID,
}, nil
}
return nil, fmt.Errorf("unsupported source type %s", s.Type)
}