Skip to content

Commit

Permalink
refactor(http): Refactor write endpoint to enable 1.x write code reuse.
Browse files Browse the repository at this point in the history
  • Loading branch information
brettbuddin committed Jun 17, 2020
1 parent 2befc27 commit 414aef2
Show file tree
Hide file tree
Showing 6 changed files with 299 additions and 243 deletions.
9 changes: 6 additions & 3 deletions http/api_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/influxdata/influxdb/v2/kit/feature"
"github.com/influxdata/influxdb/v2/kit/prom"
kithttp "github.com/influxdata/influxdb/v2/kit/transport/http"
"github.com/influxdata/influxdb/v2/models"
"github.com/influxdata/influxdb/v2/query"
"github.com/influxdata/influxdb/v2/storage"
"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -203,9 +204,11 @@ func NewAPIHandler(b *APIBackend, opts ...APIHandlerOptFn) *APIHandler {
writeBackend := NewWriteBackend(b.Logger.With(zap.String("handler", "write")), b)
h.Mount(prefixWrite, NewWriteHandler(b.Logger, writeBackend,
WithMaxBatchSizeBytes(b.MaxBatchSizeBytes),
WithParserMaxBytes(b.WriteParserMaxBytes),
WithParserMaxLines(b.WriteParserMaxLines),
WithParserMaxValues(b.WriteParserMaxValues),
WithParserOptions(
models.WithParserMaxBytes(b.WriteParserMaxBytes),
models.WithParserMaxLines(b.WriteParserMaxLines),
models.WithParserMaxValues(b.WriteParserMaxValues),
),
))

for _, o := range opts {
Expand Down
2 changes: 0 additions & 2 deletions http/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ const (
// the name. It interprets the &org= parameter as either the name
// or the ID.
func queryOrganization(ctx context.Context, r *http.Request, svc platform.OrganizationService) (o *platform.Organization, err error) {

filter := platform.OrganizationFilter{}

if organization := r.URL.Query().Get(Org); organization != "" {
if id, err := platform.IDFromString(organization); err == nil {
filter.ID = id
Expand Down
Loading

0 comments on commit 414aef2

Please sign in to comment.