github.com/influxdata/influxdb/v2@v2.7.6/source/query.go (about)

     1  package source
     2  
     3  import (
     4  	"fmt"
     5  
     6  	platform "github.com/influxdata/influxdb/v2"
     7  	"github.com/influxdata/influxdb/v2/http"
     8  	"github.com/influxdata/influxdb/v2/http/influxdb"
     9  	"github.com/influxdata/influxdb/v2/query"
    10  )
    11  
    12  // NewQueryService creates a bucket service from a source.
    13  func NewQueryService(s *platform.Source) (query.ProxyQueryService, error) {
    14  	switch s.Type {
    15  	case platform.SelfSourceType:
    16  		// TODO(fntlnz): this is supposed to call a query service directly locally,
    17  		// we are letting it err for now since we have some refactoring to do on
    18  		// how services are instantiated
    19  		return nil, fmt.Errorf("self source type not implemented")
    20  	case platform.V2SourceType:
    21  		// This is an influxd that calls another influxd, the query path is /v1/query - in future /v2/query
    22  		// it basically is the same as Self but on an external influxd.
    23  		return &http.SourceProxyQueryService{
    24  			InsecureSkipVerify: s.InsecureSkipVerify,
    25  			Addr:               s.URL,
    26  			SourceFields:       s.SourceFields,
    27  		}, nil
    28  	case platform.V1SourceType:
    29  		// This is an InfluxDB 1.7 source, which supports both InfluxQL and Flux queries
    30  		return &influxdb.SourceProxyQueryService{
    31  			InsecureSkipVerify: s.InsecureSkipVerify,
    32  			URL:                s.URL,
    33  			SourceFields:       s.SourceFields,
    34  			V1SourceFields:     s.V1SourceFields,
    35  			OrganizationID:     s.OrganizationID,
    36  		}, nil
    37  	}
    38  	return nil, fmt.Errorf("unsupported source type %s", s.Type)
    39  }