Skip to content

Commit

Permalink
chore: dedup destination metadata in router based on job id (#2982)
Browse files Browse the repository at this point in the history
  • Loading branch information
atzoum committed Feb 15, 2023
1 parent fbfd845 commit dfc2273
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"time"

jsoniter "github.com/json-iterator/go"
"github.com/samber/lo"
"github.com/tidwall/gjson"
"golang.org/x/sync/errgroup"

Expand Down Expand Up @@ -781,7 +782,11 @@ func (worker *workerT) processDestinationJobs() {
// elements in routerJobResponses have pointer to the right job.
_destinationJob := destinationJob

for _, destinationJobMetadata := range _destinationJob.JobMetadataArray {
// TODO: remove this once we enforce the necessary validations in the transformer's response
dedupedJobMetadata := lo.UniqBy(_destinationJob.JobMetadataArray, func(jobMetadata types.JobMetadataT) int64 {
return jobMetadata.JobID
})
for _, destinationJobMetadata := range dedupedJobMetadata {
_destinationJobMetadata := destinationJobMetadata
// assigning the destinationJobMetadata to a local variable (_destinationJobMetadata), so that
// elements in routerJobResponses have pointer to the right destinationJobMetadata.
Expand Down

0 comments on commit dfc2273

Please sign in to comment.