refactor(storage/readservice): rename View interface to Viewer

pull/15894/head
Chris Goller 2019-11-20 16:10:37 -06:00
parent 354b58005f
commit 0f5df301ca
3 changed files with 13 additions and 13 deletions

View File

@ -24,7 +24,7 @@ var _ Engine = (*storage.Engine)(nil)
// to facilitate testing.
type Engine interface {
influxdb.DeleteService
readservice.View
readservice.Viewer
storage.PointsWriter
storage.BucketDeleter
prom.PrometheusCollector

View File

@ -34,8 +34,8 @@ type indexSeriesCursor struct {
hasValueExpr bool
}
func newIndexSeriesCursor(ctx context.Context, src *readSource, predicate *datatypes.Predicate, view View) (*indexSeriesCursor, error) {
queries, err := view.CreateCursorIterator(ctx)
func newIndexSeriesCursor(ctx context.Context, src *readSource, predicate *datatypes.Predicate, viewer Viewer) (*indexSeriesCursor, error) {
queries, err := viewer.CreateCursorIterator(ctx)
if err != nil {
return nil, err
}
@ -74,7 +74,7 @@ func newIndexSeriesCursor(ctx context.Context, src *readSource, predicate *datat
scr := storage.SeriesCursorRequest{
Name: tsdb.EncodeName(platform.ID(src.OrganizationID), platform.ID(src.BucketID)),
}
p.sqry, err = view.CreateSeriesCursor(ctx, scr, opt.Condition)
p.sqry, err = viewer.CreateSeriesCursor(ctx, scr, opt.Condition)
if err != nil {
p.Close()
return nil, err

View File

@ -17,8 +17,8 @@ import (
"github.com/influxdata/influxql"
)
// View is used by the store to query data from time-series files.
type View interface {
// Viewer is used by the store to query data from time-series files.
type Viewer interface {
CreateCursorIterator(ctx context.Context) (tsdb.CursorIterator, error)
CreateSeriesCursor(ctx context.Context, req storage.SeriesCursorRequest, cond influxql.Expr) (storage.SeriesCursor, error)
TagKeys(ctx context.Context, orgID, bucketID influxdb.ID, start, end int64, predicate influxql.Expr) (cursors.StringIterator, error)
@ -26,12 +26,12 @@ type View interface {
}
type store struct {
view View
viewer Viewer
}
// NewStore creates a store used to query time-series data.
func NewStore(view View) reads.Store {
return &store{view: view}
func NewStore(viewer Viewer) reads.Store {
return &store{viewer: viewer}
}
func (s *store) ReadFilter(ctx context.Context, req *datatypes.ReadFilterRequest) (reads.ResultSet, error) {
@ -45,7 +45,7 @@ func (s *store) ReadFilter(ctx context.Context, req *datatypes.ReadFilterRequest
}
var cur reads.SeriesCursor
if ic, err := newIndexSeriesCursor(ctx, &source, req.Predicate, s.view); err != nil {
if ic, err := newIndexSeriesCursor(ctx, &source, req.Predicate, s.viewer); err != nil {
return nil, err
} else if ic == nil {
return nil, nil
@ -67,7 +67,7 @@ func (s *store) ReadGroup(ctx context.Context, req *datatypes.ReadGroupRequest)
}
newCursor := func() (reads.SeriesCursor, error) {
cur, err := newIndexSeriesCursor(ctx, &source, req.Predicate, s.view)
cur, err := newIndexSeriesCursor(ctx, &source, req.Predicate, s.viewer)
if cur == nil || err != nil {
return nil, err
}
@ -113,7 +113,7 @@ func (s *store) TagKeys(ctx context.Context, req *datatypes.TagKeysRequest) (cur
if err != nil {
return nil, err
}
return s.view.TagKeys(ctx, influxdb.ID(readSource.OrganizationID), influxdb.ID(readSource.BucketID), req.Range.Start, req.Range.End, expr)
return s.viewer.TagKeys(ctx, influxdb.ID(readSource.OrganizationID), influxdb.ID(readSource.BucketID), req.Range.Start, req.Range.End, expr)
}
func (s *store) TagValues(ctx context.Context, req *datatypes.TagValuesRequest) (cursors.StringIterator, error) {
@ -156,7 +156,7 @@ func (s *store) TagValues(ctx context.Context, req *datatypes.TagValuesRequest)
if err != nil {
return nil, err
}
return s.view.TagValues(ctx, influxdb.ID(readSource.OrganizationID), influxdb.ID(readSource.BucketID), req.TagKey, req.Range.Start, req.Range.End, expr)
return s.viewer.TagValues(ctx, influxdb.ID(readSource.OrganizationID), influxdb.ID(readSource.BucketID), req.TagKey, req.Range.Start, req.Range.End, expr)
}
// this is easier than fooling around with .proto files.