Skip to content

Commit

Permalink
Fixing newHandlers population
Browse files Browse the repository at this point in the history
  • Loading branch information
pdelewski committed Dec 21, 2024
1 parent 94e664e commit d53daad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
3 changes: 0 additions & 3 deletions quesma/quesma/dual_write_proxy_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ func newDualWriteProxyV2(dependencies quesma_api.Dependencies, schemaLoader clic

queryPipeline := quesma_api.NewPipeline()
queryPipeline.AddFrontendConnector(elasticHttpQueryFrontendConnector)
// TODO the order of pipelines is important
// that's due current bug/limitation in quesma.Build() method
// listener in the case of the same tcp port has to be shared
quesmaBuilder.AddPipeline(queryPipeline)
quesmaBuilder.AddPipeline(ingestPipeline)

Expand Down
16 changes: 11 additions & 5 deletions quesma/v2/core/mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,20 @@ func (p *PathRouter) GetHandlers() map[string]HandlersPipe {
func (p *PathRouter) SetHandlers(handlers map[string]HandlersPipe) {
newHandlers := make(map[string]HandlersPipe, 0)
for path, handler := range handlers {
for index := range p.mappings {
var index int
var found bool
for index = range p.mappings {
if p.mappings[index].pattern == path {
p.mappings[index].handler.Processors = handler.Processors
p.mappings[index].handler.Predicate = handler.Predicate
} else {
newHandlers[path] = handler
found = true
break
}
}
if found {
p.mappings[index].handler.Processors = handler.Processors
p.mappings[index].handler.Predicate = handler.Predicate
} else {
newHandlers[path] = handler
}
}
for path, handler := range newHandlers {
p.mappings = append(p.mappings, mapping{pattern: path,
Expand Down

0 comments on commit d53daad

Please sign in to comment.