Skip to content

Commit

Permalink
Quesma v2 splitted routing fixes (#1058)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdelewski authored Dec 2, 2024
1 parent 24cb3f4 commit 61d0d96
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions quesma/quesma/dual_write_proxy_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func (*routerV2) closedIndexResponse(ctx context.Context, w http.ResponseWriter,

}

func (r *routerV2) reroute(ctx context.Context, w http.ResponseWriter, req *http.Request, reqBody []byte, pathRouter *mux.PathRouter, ingestRouter *mux.PathRouter, logManager *clickhouse.LogManager) {
func (r *routerV2) reroute(ctx context.Context, w http.ResponseWriter, req *http.Request, reqBody []byte, searchRouter *mux.PathRouter, ingestRouter *mux.PathRouter, logManager *clickhouse.LogManager) {
defer recovery.LogAndHandlePanic(ctx, func(err error) {
w.WriteHeader(500)
w.Write(queryparser.InternalQuesmaError("Unknown Quesma error"))
Expand All @@ -308,18 +308,20 @@ func (r *routerV2) reroute(ctx context.Context, w http.ResponseWriter, req *http
quesmaRequest.ParsedBody = types.ParseRequestBody(quesmaRequest.Body)
var handler mux.Handler
var decision *table_resolver.Decision

searchHandler, searchDecision := pathRouter.Matches(quesmaRequest)
searchHandler, searchDecision := searchRouter.Matches(quesmaRequest)
if searchDecision != nil {
decision = searchDecision
}
if searchHandler != nil {
handler = searchHandler
}
ingestHandler, ingestDecision := ingestRouter.Matches(quesmaRequest)

if searchDecision == nil {
decision = ingestDecision
}
if searchHandler == nil {
handler = ingestHandler
decision = ingestDecision
} else {
handler = searchHandler
decision = searchDecision
}

if decision != nil {
w.Header().Set(quesmaTableResolverHeader, decision.String())
} else {
Expand Down

0 comments on commit 61d0d96

Please sign in to comment.