Skip to content

Commit

Permalink
chore: Define interface api.Distributor (#4297)
Browse files Browse the repository at this point in the history
This allows reusing the API handler while swapping out the Ddistributor
implementation.

Signed-off-by: Christian Simon <[email protected]>
  • Loading branch information
simonswine authored Jun 22, 2021
1 parent ceb4646 commit 20f8931
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 6 additions & 1 deletion pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,16 @@ func (a *API) RegisterCompactor(c *compactor.Compactor) {
a.RegisterRoute("/compactor/ring", http.HandlerFunc(c.RingHandler), false, "GET", "POST")
}

type Distributor interface {
querier.Distributor
UserStatsHandler(w http.ResponseWriter, r *http.Request)
}

// RegisterQueryable registers the the default routes associated with the querier
// module.
func (a *API) RegisterQueryable(
queryable storage.SampleAndChunkQueryable,
distributor *distributor.Distributor,
distributor Distributor,
) {
// these routes are always registered to the default server
a.RegisterRoute("/api/v1/user_stats", http.HandlerFunc(distributor.UserStatsHandler), true, "GET")
Expand Down
3 changes: 1 addition & 2 deletions pkg/api/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/weaveworks/common/middleware"

"github.com/cortexproject/cortex/pkg/chunk/purger"
"github.com/cortexproject/cortex/pkg/distributor"
"github.com/cortexproject/cortex/pkg/querier"
"github.com/cortexproject/cortex/pkg/querier/stats"
"github.com/cortexproject/cortex/pkg/util"
Expand Down Expand Up @@ -160,7 +159,7 @@ func NewQuerierHandler(
queryable storage.SampleAndChunkQueryable,
exemplarQueryable storage.ExemplarQueryable,
engine *promql.Engine,
distributor *distributor.Distributor,
distributor Distributor,
tombstonesLoader *purger.TombstonesLoader,
reg prometheus.Registerer,
logger log.Logger,
Expand Down

0 comments on commit 20f8931

Please sign in to comment.