Skip to content

Commit

Permalink
lint and build fix
Browse files Browse the repository at this point in the history
Signed-off-by: Cyril Tovena <[email protected]>
  • Loading branch information
cyriltovena committed Nov 9, 2020
1 parent ff1ba6f commit 0c7df78
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 21 deletions.
2 changes: 1 addition & 1 deletion pkg/logcli/query/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func (q *Query) DoLocalQuery(out output.LogOutput, statistics bool, orgID string
return err
}

eng := logql.NewEngine(conf.Querier.Engine, querier)
eng := logql.NewEngine(conf.Querier.Engine, querier, limits)
var query logql.Query

if q.isInstant() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/logcli/query/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ type testQueryClient struct {

func newTestQueryClient(testStreams ...logproto.Stream) *testQueryClient {
q := logql.NewMockQuerier(0, testStreams)
e := logql.NewEngine(logql.EngineOpts{}, q)
e := logql.NewEngine(logql.EngineOpts{}, q, logql.NoLimits)
return &testQueryClient{
engine: e,
queryRangeCalls: 0,
Expand Down
5 changes: 0 additions & 5 deletions pkg/logql/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,6 @@ type Engine struct {
limits Limits
}

// Limits allow the engine to fetch limits for a given users.
type Limits interface {
MaxQuerySeries(userID string) int
}

// NewEngine creates a new LogQL Engine.
func NewEngine(opts EngineOpts, q Querier, l Limits) *Engine {
opts.applyDefault()
Expand Down
9 changes: 0 additions & 9 deletions pkg/logql/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,8 @@ var (
testSize = int64(300)
ErrMock = errors.New("mock error")
ErrMockMultiple = errors.New("Multiple errors: [mock error mock error]")
NoLimits = &fakeLimits{maxSeries: math.MaxInt32}
)

type fakeLimits struct {
maxSeries int
}

func (f fakeLimits) MaxQuerySeries(userID string) int {
return f.maxSeries
}

func TestEngine_LogsInstantQuery(t *testing.T) {
t.Parallel()
for _, test := range []struct {
Expand Down
22 changes: 22 additions & 0 deletions pkg/logql/limits.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package logql

import (
"math"
)

var (
NoLimits = &fakeLimits{maxSeries: math.MaxInt32}
)

// Limits allow the engine to fetch limits for a given users.
type Limits interface {
MaxQuerySeries(userID string) int
}

type fakeLimits struct {
maxSeries int
}

func (f fakeLimits) MaxQuerySeries(userID string) int {
return f.maxSeries
}
7 changes: 4 additions & 3 deletions pkg/querier/queryrange/limits_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ import (
"github.com/cortexproject/cortex/pkg/chunk"
"github.com/cortexproject/cortex/pkg/querier/queryrange"
"github.com/cortexproject/cortex/pkg/util"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql"
"github.com/grafana/loki/pkg/logql/marshal"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/promql"
"github.com/stretchr/testify/require"
"github.com/weaveworks/common/user"

"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql"
"github.com/grafana/loki/pkg/logql/marshal"
)

func TestLimits(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/querier/queryrange/querysharding.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewQueryShardMiddleware(
minShardingLookback time.Duration,
middlewareMetrics *queryrange.InstrumentMiddlewareMetrics,
shardingMetrics *logql.ShardingMetrics,
limits Limits,
limits logql.Limits,
) queryrange.Middleware {

noshards := !hasShards(confs)
Expand Down Expand Up @@ -61,7 +61,7 @@ func newASTMapperware(
next queryrange.Handler,
logger log.Logger,
metrics *logql.ShardingMetrics,
limits Limits,
limits logql.Limits,
) *astMapperware {

return &astMapperware{
Expand Down

0 comments on commit 0c7df78

Please sign in to comment.