Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions internal/app/configupdates.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,15 @@ func (processor *ConfigUpdateProcessor) processConfigChangedPipeline() {
sdk.runtime.TargetType = sdk.targetType

// Update the pipelines with their new transforms
for _, pipeline := range pipelines {
// TODO: Look at better way to apply pipeline updates
sdk.runtime.SetFunctionsPipelineTransforms(pipeline.Id, pipeline.Transforms)
sdk.runtime.SetFunctionsPipelineTopics(pipeline.Id, pipeline.Topics)
for i, pipline := range pipelines {
var fullTopics []string
for _, topic := range pipline.Topics {
fullTopics = append(fullTopics, coreCommon.BuildTopic(sdk.config.MessageBus.GetBaseTopicPrefix(), topic))
}
Comment on lines +155 to +158
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that the logic here is very similar to what the getFullTopics func already does. To avoid duplicating logic, would it be possible to refactor this to call getFullTopics instead?

pipline.Topics = fullTopics
pipelines[i] = pipline
}
sdk.runtime.UpdateFunctionsPipelines(pipelines)

sdk.LoggingClient().Info("Configurable Pipeline successfully reloaded from new configuration")
}
Expand Down
22 changes: 22 additions & 0 deletions internal/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,28 @@ func (fpr *FunctionsPipelineRuntime) RemoveAllFunctionPipelines() {
fpr.isBusyCopying.Unlock()
}

func (fpr *FunctionsPipelineRuntime) UpdateFunctionsPipelines(piplines map[string]interfaces.FunctionPipeline) {
fpr.isBusyCopying.Lock()
defer fpr.isBusyCopying.Unlock()

metricManager := bootstrapContainer.MetricsManagerFrom(fpr.dic.Get)
for _, curPipline := range fpr.pipelines {
if _, ok := piplines[curPipline.Id]; !ok {
fpr.unregisterPipelineMetric(metricManager, internal.PipelineMessagesProcessedName, curPipline.Id)
fpr.unregisterPipelineMetric(metricManager, internal.PipelineMessageProcessingTimeName, curPipline.Id)
fpr.unregisterPipelineMetric(metricManager, internal.PipelineProcessingErrorsName, curPipline.Id)
delete(fpr.pipelines, curPipline.Id)
}
}
for _, toAdd := range piplines {
pipeline := NewFunctionPipeline(toAdd.Id, toAdd.Topics, toAdd.Transforms)
fpr.pipelines[toAdd.Id] = &pipeline
fpr.registerPipelineMetric(metricManager, internal.PipelineMessagesProcessedName, pipeline.Id, pipeline.MessagesProcessed)
fpr.registerPipelineMetric(metricManager, internal.PipelineMessageProcessingTimeName, pipeline.Id, pipeline.MessageProcessingTime)
fpr.registerPipelineMetric(metricManager, internal.PipelineProcessingErrorsName, pipeline.Id, pipeline.ProcessingErrors)
}
}

// AddFunctionsPipeline is thread safe to set transforms
func (fpr *FunctionsPipelineRuntime) AddFunctionsPipeline(id string, topics []string, transforms []interfaces.AppFunction) error {
_, exists := fpr.pipelines[id]
Expand Down