Skip to content

Commit

Permalink
Refactor BuildSyncers
Browse files Browse the repository at this point in the history
Refactor BuildSyncers to use map[string]config.BidderInfo instead of map[string]config.Syncer. This is done because config.BidderInfo is needed to determine if bidder is an alias or non-alias bidder.
  • Loading branch information
onkarvhanumante committed Sep 6, 2023
1 parent d96281a commit ce30fda
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions usersync/syncersbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ func (e SyncerBuildError) Error() string {
}

func BuildSyncers(hostConfig *config.Configuration, bidderInfos config.BidderInfos) (map[string]Syncer, []error) {
// map syncer config by bidder
cfgByBidder := make(map[string]config.Syncer, len(bidderInfos))
biddersWithSyncerCfg := make(map[string]config.BidderInfo, len(bidderInfos))
for bidder, bidderInfo := range bidderInfos {
if shouldCreateSyncer(bidderInfo) {
cfgByBidder[bidder] = *bidderInfo.Syncer
biddersWithSyncerCfg[bidder] = bidderInfo
}
}

// map syncer config by key
cfgBySyncerKey := make(map[string][]namedSyncerConfig, len(bidderInfos))
for bidder, cfg := range cfgByBidder {
if cfg.Key == "" {
cfg.Key = bidder
for bidder, bidderInfo := range biddersWithSyncerCfg {
syncerCopy := *bidderInfo.Syncer
if syncerCopy.Key == "" {
syncerCopy.Key = bidder
}
cfgBySyncerKey[cfg.Key] = append(cfgBySyncerKey[cfg.Key], namedSyncerConfig{bidder, cfg})
cfgBySyncerKey[syncerCopy.Key] = append(cfgBySyncerKey[syncerCopy.Key], namedSyncerConfig{bidder, syncerCopy})
}

// resolve host endpoint
Expand Down

0 comments on commit ce30fda

Please sign in to comment.