refactor(http): prefer Addr over URL in field names

The other services all use the field Addr, so consistently use Addr,
instead of sometimes using URL.
pull/10616/head
Mark Rushakoff 2018-10-04 12:11:45 -07:00 committed by Mark Rushakoff
parent 9939e7fad0
commit 955eabd551
5 changed files with 11 additions and 11 deletions

View File

@ -50,7 +50,7 @@ func replF(cmd *cobra.Command, args []string) {
func getFluxREPL(addr, token string, orgID platform.ID) (*repl.REPL, error) {
qs := &http.FluxQueryService{
URL: addr,
Addr: addr,
Token: token,
}
q := &query.REPLQuerier{

View File

@ -102,7 +102,7 @@ var _ query.ProxyQueryService = (*FluxService)(nil)
// FluxService connects to Influx via HTTP using tokens to run queries.
type FluxService struct {
URL string
Addr string
Token string
InsecureSkipVerify bool
}
@ -110,7 +110,7 @@ type FluxService struct {
// Query runs a flux query against a influx server and sends the results to the io.Writer.
// Will use the token from the context over the token within the service struct.
func (s *FluxService) Query(ctx context.Context, w io.Writer, r *query.ProxyRequest) (int64, error) {
u, err := newURL(s.URL, fluxPath)
u, err := newURL(s.Addr, fluxPath)
if err != nil {
return 0, err
}
@ -156,14 +156,14 @@ var _ query.QueryService = (*FluxQueryService)(nil)
// FluxQueryService implements query.QueryService by making HTTP requests to the /api/v2/query API endpoint.
type FluxQueryService struct {
URL string
Addr string
Token string
InsecureSkipVerify bool
}
// Query runs a flux query against a influx server and decodes the result
func (s *FluxQueryService) Query(ctx context.Context, r *query.Request) (flux.ResultIterator, error) {
u, err := newURL(s.URL, fluxPath)
u, err := newURL(s.Addr, fluxPath)
if err != nil {
return nil, err
}

View File

@ -66,7 +66,7 @@ func TestFluxService_Query(t *testing.T) {
}))
defer ts.Close()
s := &FluxService{
URL: ts.URL,
Addr: ts.URL,
Token: tt.token,
}
@ -137,7 +137,7 @@ func TestFluxQueryService_Query(t *testing.T) {
fmt.Fprintln(w, tt.csv)
}))
s := &FluxQueryService{
URL: ts.URL,
Addr: ts.URL,
Token: tt.token,
}
res, err := s.Query(tt.ctx, tt.r)

View File

@ -17,8 +17,8 @@ import (
)
type SourceProxyQueryService struct {
Addr string
InsecureSkipVerify bool
URL string
platform.SourceFields
}
@ -33,7 +33,7 @@ func (s *SourceProxyQueryService) Query(ctx context.Context, w io.Writer, req *q
}
func (s *SourceProxyQueryService) queryFlux(ctx context.Context, w io.Writer, req *query.ProxyRequest) (int64, error) {
u, err := newURL(s.URL, "/api/v2/query")
u, err := newURL(s.Addr, "/api/v2/query")
if err != nil {
return 0, err
}
@ -69,7 +69,7 @@ func (s *SourceProxyQueryService) queryInfluxQL(ctx context.Context, w io.Writer
return 0, fmt.Errorf("compiler is not of type 'influxql'")
}
u, err := newURL(s.URL, "/query")
u, err := newURL(s.Addr, "/query")
if err != nil {
return 0, err
}

View File

@ -22,7 +22,7 @@ func NewQueryService(s *platform.Source) (query.ProxyQueryService, error) {
// it basically is the same as Self but on an external influxd.
return &http.SourceProxyQueryService{
InsecureSkipVerify: s.InsecureSkipVerify,
URL: s.URL,
Addr: s.URL,
SourceFields: s.SourceFields,
}, nil
case platform.V1SourceType: