Skip to content

Commit

Permalink
Use new gate.Gate implementation
Browse files Browse the repository at this point in the history
Signed-off-by: Kemal Akkoyun <[email protected]>
  • Loading branch information
kakkoyun committed Jun 16, 2020
1 parent 48485f2 commit c611490
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/query/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (
"github.com/opentracing/opentracing-go"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/prometheus/pkg/gate"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/storage"

"github.com/thanos-io/thanos/pkg/gate"
"github.com/thanos-io/thanos/pkg/store/storepb"
"github.com/thanos-io/thanos/pkg/tracing"
)
Expand All @@ -31,6 +31,8 @@ type QueryableCreator func(deduplicate bool, replicaLabels []string, maxResoluti

// NewQueryableCreator creates QueryableCreator.
func NewQueryableCreator(logger log.Logger, reg prometheus.Registerer, proxy storepb.StoreServer, maxConcurrentSelects int, selectTimeout time.Duration) QueryableCreator {
keeper := gate.NewKeeper(reg)

return func(deduplicate bool, replicaLabels []string, maxResolutionMillis int64, partialResponse, skipChunks bool) storage.Queryable {
return &queryable{
logger: logger,
Expand All @@ -41,6 +43,7 @@ func NewQueryableCreator(logger log.Logger, reg prometheus.Registerer, proxy sto
maxResolutionMillis: maxResolutionMillis,
partialResponse: partialResponse,
skipChunks: skipChunks,
gateKeeper: keeper,
maxConcurrentSelects: maxConcurrentSelects,
selectTimeout: selectTimeout,
}
Expand All @@ -56,13 +59,14 @@ type queryable struct {
maxResolutionMillis int64
partialResponse bool
skipChunks bool
gateKeeper *gate.Keeper
maxConcurrentSelects int
selectTimeout time.Duration
}

// Querier returns a new storage querier against the underlying proxy store API.
func (q *queryable) Querier(ctx context.Context, mint, maxt int64) (storage.Querier, error) {
return newQuerier(ctx, q.logger, q.reg, mint, maxt, q.replicaLabels, q.proxy, q.deduplicate, q.maxResolutionMillis, q.partialResponse, q.skipChunks, gate.New(q.maxConcurrentSelects), q.selectTimeout), nil
return newQuerier(ctx, q.logger, q.reg, mint, maxt, q.replicaLabels, q.proxy, q.deduplicate, q.maxResolutionMillis, q.partialResponse, q.skipChunks, q.gateKeeper.NewGate(q.maxConcurrentSelects), q.selectTimeout), nil
}

type querier struct {
Expand All @@ -77,7 +81,7 @@ type querier struct {
maxResolutionMillis int64
partialResponse bool
skipChunks bool
selectGate *gate.Gate
selectGate gate.Gate
selectTimeout time.Duration
}

Expand All @@ -93,7 +97,7 @@ func newQuerier(
deduplicate bool,
maxResolutionMillis int64,
partialResponse, skipChunks bool,
selectGate *gate.Gate,
selectGate gate.Gate,
selectTimeout time.Duration,
) *querier {
if logger == nil {
Expand Down

0 comments on commit c611490

Please sign in to comment.