We are moving the necessary code for 2.0 from the influxdb 1.X
repository to the platform 2.0 repository. The logger is an unnecessary
dependency on the old influxdb that is making life more complicated.
The pb package was only referenced in cmd/influx/query.go, but in
dead code, since it uses the same machinery as the repl, which goes
through the HTTP endpoints, rather than the gRPC endpoints.
This pulls in the code that allows doing reads with flux into the
platform repo, and removes extra.go.
The reusable portion is under storage/reads, where the concrete
implementation for one of the platform's engines is in
storage/readservice.
In order to make this more reusable, the cursors had to move into
their own package, decoupling it from all of the other code in the
tsdb package. tsdb/cursors is this new package, and type/function
aliases have been added to the tsdb package to point at it.
The models package already is very light on transitive dependencies
and so it was allowed to be depended on in a concrete way in the
cursors package.
Finally, the protobuf definitions for issuing GRPC reads has been
moved into its own package for two reasons:
1. It's a clean separation, and helps keep it that way.
2. Many/most consumers will not be using GRPC. We just
use the datatypes to express the API which helps making
a GRPC server easier.
It is left up to future refactorings (specifically ones that involve
GPRC) to determine if these types should remain, or if there is a
cleaner way.
There's still some dependencies on both github.com/influxdata/influxql
and github.com/influxdata/influxdb/logger that we can hopefully remove
in future refactorings.
We reorganized the functions in flux to have the structure:
/functions
/inputs
/transformations
/outputs
this PR catches up platform to work with the new package layout.
As a separate refactoring issue, we should discuss:
from(bucket: ) should migrate from flux --> platform
to_http and to_kafka should migrate from platform --> flux
The race detector was picking up a data race because of the
unsynchronized reassignment of ctx:
```
$ go run -race ./cmd/influxd
...
^C
==================
WARNING: DATA RACE
Write at 0x00c00053d220 by main goroutine:
main.platformF()
/Users/mr/gomod/platform/cmd/influxd/main.go:381 +0x2cf7
github.com/spf13/cobra.(*Command).execute()
/Users/mr/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:766 +0x8b2
github.com/spf13/cobra.(*Command).ExecuteC()
/Users/mr/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:852 +0x432
github.com/spf13/cobra.(*Command).Execute()
/Users/mr/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:800 +0x38
main.Execute()
/Users/mr/gomod/platform/cmd/influxd/main.go:388 +0x4e
main.main()
/Users/mr/gomod/platform/cmd/influxd/main.go:46 +0x2f
Previous read at 0x00c00053d220 by goroutine 147:
main.platformF.func1()
/Users/mr/gomod/platform/cmd/influxd/main.go:330 +0x3c
Goroutine 147 (running) created at:
main.platformF()
/Users/mr/gomod/platform/cmd/influxd/main.go:329 +0x2554
github.com/spf13/cobra.(*Command).execute()
/Users/mr/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:766 +0x8b2
github.com/spf13/cobra.(*Command).ExecuteC()
/Users/mr/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:852 +0x432
github.com/spf13/cobra.(*Command).Execute()
/Users/mr/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:800 +0x38
main.Execute()
/Users/mr/gomod/platform/cmd/influxd/main.go:388 +0x4e
main.main()
/Users/mr/gomod/platform/cmd/influxd/main.go:46 +0x2f
==================
```
So just assign context.WithCancel to a new variable instead.