Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
pdelewski committed Dec 27, 2024
1 parent 1576c30 commit 30b85bb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
10 changes: 5 additions & 5 deletions quesma/frontend_connectors/basic_http_frontend_connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type BasicHTTPFrontendConnector struct {
debugInfoCollector diag.DebugInfoCollector
logger quesma_api.QuesmaLogger
middlewares []http.Handler
currentListener quesma_api.FrontendConnector
connector quesma_api.FrontendConnector
}

func (h *BasicHTTPFrontendConnector) GetChildComponents() []interface{} {
Expand Down Expand Up @@ -184,10 +184,10 @@ func (h *BasicHTTPFrontendConnector) AddMiddleware(middleware http.Handler) {
h.middlewares = append(h.middlewares, middleware)
}

func (h *BasicHTTPFrontendConnector) SetListener(listener quesma_api.FrontendConnector) {
h.currentListener = listener
func (h *BasicHTTPFrontendConnector) SetConnector(connector quesma_api.FrontendConnector) {
h.connector = connector
}

func (h *BasicHTTPFrontendConnector) Listener() quesma_api.FrontendConnector {
return h.currentListener
func (h *BasicHTTPFrontendConnector) Connector() quesma_api.FrontendConnector {
return h.connector
}
12 changes: 10 additions & 2 deletions quesma/v2/core/quesma_apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,16 @@ type Router interface {

type FrontendConnector interface {
InstanceNamer
SetListener(listener FrontendConnector)
Listener() FrontendConnector
// SetConnector sets the connector
// Connectors are the components that listen for incoming requests
// They can be shared for instance in the case when
// the same tcp port is used
// SetConnector and Connector are used to set and get the connector
// and merge the connectors
SetConnector(listener FrontendConnector)
// Connector returns the connector
Connector() FrontendConnector
// Listen starts listening on the endpoint
Listen() error // Start listening on the endpoint
GetEndpoint() string
Stop(ctx context.Context) error // Stop listening
Expand Down
2 changes: 1 addition & 1 deletion quesma/v2/core/quesma_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (quesma *Quesma) buildInternal() (QuesmaBuilder, error) {
}
for pipelineIndex, _ := range quesma.pipelines {
for frontendConnectorIndex := range quesma.pipelines[pipelineIndex].GetFrontendConnectors() {
quesma.pipelines[pipelineIndex].GetFrontendConnectors()[frontendConnectorIndex].SetListener(quesma.pipelines[0].GetFrontendConnectors()[0])
quesma.pipelines[pipelineIndex].GetFrontendConnectors()[frontendConnectorIndex].SetConnector(quesma.pipelines[0].GetFrontendConnectors()[0])
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion quesma/v2/core/quesma_pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ func (p *Pipeline) Start() {
// however, bind error remains
for _, conn := range p.FrontendConnectors {
p.logger.Info().Msgf("Starting frontend connector %s", conn)
go conn.Listener().Listen()
go func() {
err := conn.Connector().Listen()
if err != nil {
p.logger.Error().Err(err).Msgf("Failed to start frontend connector %s", conn)
}
}()
}
}

Expand Down

0 comments on commit 30b85bb

Please sign in to comment.