@@ -27,9 +27,10 @@ import (
2727 "quesma/schema"
2828 "quesma/table_resolver"
2929 "quesma/telemetry"
30- "quesma/tracing"
3130 "quesma/util"
32- "quesma_v2/core/mux"
31+ quesma_api "quesma_v2/core"
32+ tracing "quesma_v2/core/tracing"
33+
3334 "quesma_v2/core/routes"
3435 "strconv"
3536 "strings"
@@ -102,9 +103,9 @@ func newDualWriteProxyV2(schemaLoader clickhouse.TableDiscovery, logManager *cli
102103 Transport : tr ,
103104 Timeout : time .Minute , // should be more configurable, 30s is Kibana default timeout
104105 }
105- routerInstance := routerV2 {phoneHomeAgent : agent , config : config , quesmaManagementConsole : quesmaManagementConsole , httpClient : client , requestPreprocessors : processorChain {}}
106+ routerInstance := routerV2 {phoneHomeAgent : agent , config : config , quesmaManagementConsole : quesmaManagementConsole , httpClient : client , requestPreprocessors : quesma_api. ProcessorChain {}}
106107 routerInstance .
107- registerPreprocessor (NewTraceIdPreprocessor ())
108+ registerPreprocessor (quesma_api . NewTraceIdPreprocessor ())
108109 agent .FailedRequestsCollector (func () int64 {
109110 return routerInstance .failedRequests .Load ()
110111 })
@@ -181,7 +182,7 @@ func responseFromElasticV2(ctx context.Context, elkResponse *http.Response, w ht
181182 elkResponse .Body .Close ()
182183}
183184
184- func responseFromQuesmaV2 (ctx context.Context , unzipped []byte , w http.ResponseWriter , quesmaResponse * mux .Result , zip bool ) {
185+ func responseFromQuesmaV2 (ctx context.Context , unzipped []byte , w http.ResponseWriter , quesmaResponse * quesma_api .Result , zip bool ) {
185186 id := ctx .Value (tracing .RequestIdCtxKey ).(string )
186187 logger .Debug ().Str (logger .RID , id ).Msg ("responding from Quesma" )
187188
@@ -206,14 +207,14 @@ func responseFromQuesmaV2(ctx context.Context, unzipped []byte, w http.ResponseW
206207
207208type routerV2 struct {
208209 config * config.QuesmaConfiguration
209- requestPreprocessors processorChain
210+ requestPreprocessors quesma_api. ProcessorChain
210211 quesmaManagementConsole * ui.QuesmaManagementConsole
211212 phoneHomeAgent telemetry.PhoneHomeAgent
212213 httpClient * http.Client
213214 failedRequests atomic.Int64
214215}
215216
216- func (r * routerV2 ) registerPreprocessor (preprocessor RequestPreprocessor ) {
217+ func (r * routerV2 ) registerPreprocessor (preprocessor quesma_api. RequestPreprocessor ) {
217218 r .requestPreprocessors = append (r .requestPreprocessors , preprocessor )
218219}
219220
@@ -222,7 +223,7 @@ func (r *routerV2) errorResponseV2(ctx context.Context, err error, w http.Respon
222223
223224 msg := "Internal Quesma Error.\n Please contact support if the problem persists."
224225 reason := "Failed request."
225- result := mux .ServerErrorResult ()
226+ result := quesma_api .ServerErrorResult ()
226227
227228 // if error is an error with user-friendly message, we should use it
228229 var endUserError * end_user_errors.EndUserError
@@ -232,7 +233,7 @@ func (r *routerV2) errorResponseV2(ctx context.Context, err error, w http.Respon
232233
233234 // we treat all `Q1xxx` errors as bad requests here
234235 if endUserError .ErrorType ().Number < 2000 {
235- result = mux .BadReqeustResult ()
236+ result = quesma_api .BadReqeustResult ()
236237 }
237238 }
238239
@@ -275,7 +276,7 @@ func (*routerV2) closedIndexResponse(ctx context.Context, w http.ResponseWriter,
275276
276277}
277278
278- func (r * routerV2 ) elasticFallback (decision * mux .Decision ,
279+ func (r * routerV2 ) elasticFallback (decision * quesma_api .Decision ,
279280 ctx context.Context , w http.ResponseWriter ,
280281 req * http.Request , reqBody []byte , logManager * clickhouse.LogManager ) {
281282
@@ -306,7 +307,7 @@ func (r *routerV2) elasticFallback(decision *mux.Decision,
306307 }
307308
308309 for _ , connector := range decision .UseConnectors {
309- if _ , ok := connector .(* mux .ConnectorDecisionElastic ); ok {
310+ if _ , ok := connector .(* quesma_api .ConnectorDecisionElastic ); ok {
310311 // this is desired elastic call
311312 sendToElastic = true
312313 break
@@ -338,13 +339,13 @@ func (r *routerV2) elasticFallback(decision *mux.Decision,
338339 }
339340}
340341
341- func (r * routerV2 ) reroute (ctx context.Context , w http.ResponseWriter , req * http.Request , reqBody []byte , searchRouter * mux .PathRouter , ingestRouter * mux .PathRouter , logManager * clickhouse.LogManager ) {
342+ func (r * routerV2 ) reroute (ctx context.Context , w http.ResponseWriter , req * http.Request , reqBody []byte , searchRouter * quesma_api .PathRouter , ingestRouter * quesma_api .PathRouter , logManager * clickhouse.LogManager ) {
342343 defer recovery .LogAndHandlePanic (ctx , func (err error ) {
343344 w .WriteHeader (500 )
344345 w .Write (queryparser .InternalQuesmaError ("Unknown Quesma error" ))
345346 })
346347
347- quesmaRequest , ctx , err := r .preprocessRequest (ctx , & mux .Request {
348+ quesmaRequest , ctx , err := r .preprocessRequest (ctx , & quesma_api .Request {
348349 Method : req .Method ,
349350 Path : strings .TrimSuffix (req .URL .Path , "/" ),
350351 Params : map [string ]string {},
@@ -358,8 +359,8 @@ func (r *routerV2) reroute(ctx context.Context, w http.ResponseWriter, req *http
358359 }
359360
360361 quesmaRequest .ParsedBody = types .ParseRequestBody (quesmaRequest .Body )
361- var handler mux .Handler
362- var decision * mux .Decision
362+ var handler quesma_api .Handler
363+ var decision * quesma_api .Decision
363364 searchHandler , searchDecision := searchRouter .Matches (quesmaRequest )
364365 if searchDecision != nil {
365366 decision = searchDecision
@@ -381,7 +382,7 @@ func (r *routerV2) reroute(ctx context.Context, w http.ResponseWriter, req *http
381382 }
382383
383384 if handler != nil {
384- quesmaResponse , err := recordRequestToClickhouseV2 (req .URL .Path , r .quesmaManagementConsole , func () (* mux .Result , error ) {
385+ quesmaResponse , err := recordRequestToClickhouseV2 (req .URL .Path , r .quesmaManagementConsole , func () (* quesma_api .Result , error ) {
385386 return handler (ctx , quesmaRequest )
386387 })
387388
@@ -408,7 +409,7 @@ func (r *routerV2) reroute(ctx context.Context, w http.ResponseWriter, req *http
408409 }
409410}
410411
411- func (r * routerV2 ) preprocessRequest (ctx context.Context , quesmaRequest * mux .Request ) (* mux .Request , context.Context , error ) {
412+ func (r * routerV2 ) preprocessRequest (ctx context.Context , quesmaRequest * quesma_api .Request ) (* quesma_api .Request , context.Context , error ) {
412413 var err error
413414 var processedRequest = quesmaRequest
414415 for _ , preprocessor := range r .requestPreprocessors {
@@ -482,7 +483,7 @@ func isIngestV2(path string) bool {
482483 return strings .HasSuffix (path , routes .BulkPath ) // We may add more methods in future such as `_put` or `_create`
483484}
484485
485- func recordRequestToClickhouseV2 (path string , qmc * ui.QuesmaManagementConsole , requestFunc func () (* mux .Result , error )) (* mux .Result , error ) {
486+ func recordRequestToClickhouseV2 (path string , qmc * ui.QuesmaManagementConsole , requestFunc func () (* quesma_api .Result , error )) (* quesma_api .Result , error ) {
486487 statName := ui .RequestStatisticKibana2Clickhouse
487488 if isIngestV2 (path ) {
488489 statName = ui .RequestStatisticIngest2Clickhouse
0 commit comments