Skip to content

Commit 20f8931

Browse files
authored
chore: Define interface api.Distributor (#4297)
This allows reusing the API handler while swapping out the Ddistributor implementation. Signed-off-by: Christian Simon <simon@swine.de>
1 parent ceb4646 commit 20f8931

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

pkg/api/api.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,11 +351,16 @@ func (a *API) RegisterCompactor(c *compactor.Compactor) {
351351
a.RegisterRoute("/compactor/ring", http.HandlerFunc(c.RingHandler), false, "GET", "POST")
352352
}
353353

354+
type Distributor interface {
355+
querier.Distributor
356+
UserStatsHandler(w http.ResponseWriter, r *http.Request)
357+
}
358+
354359
// RegisterQueryable registers the the default routes associated with the querier
355360
// module.
356361
func (a *API) RegisterQueryable(
357362
queryable storage.SampleAndChunkQueryable,
358-
distributor *distributor.Distributor,
363+
distributor Distributor,
359364
) {
360365
// these routes are always registered to the default server
361366
a.RegisterRoute("/api/v1/user_stats", http.HandlerFunc(distributor.UserStatsHandler), true, "GET")

pkg/api/handlers.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"github.com/weaveworks/common/middleware"
2424

2525
"github.com/cortexproject/cortex/pkg/chunk/purger"
26-
"github.com/cortexproject/cortex/pkg/distributor"
2726
"github.com/cortexproject/cortex/pkg/querier"
2827
"github.com/cortexproject/cortex/pkg/querier/stats"
2928
"github.com/cortexproject/cortex/pkg/util"
@@ -160,7 +159,7 @@ func NewQuerierHandler(
160159
queryable storage.SampleAndChunkQueryable,
161160
exemplarQueryable storage.ExemplarQueryable,
162161
engine *promql.Engine,
163-
distributor *distributor.Distributor,
162+
distributor Distributor,
164163
tombstonesLoader *purger.TombstonesLoader,
165164
reg prometheus.Registerer,
166165
logger log.Logger,

0 commit comments

Comments
 (0)