Skip to content

Commit

Permalink
fix test;add more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongshixi committed Oct 22, 2024
1 parent e0b1be2 commit 0a5b937
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
6 changes: 4 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,12 @@ type Privacy struct {
}

type VendorListFetcher struct {
// Max concurrent request for downloading the latest version of the vendor list from a specific major version
// Max concurrent request for downloading the latest version of the vendor list from a specific major version.
// If it is 0 or negative, then means there is no limit for the max concurrency.
MaxConcurrencyInitFetchLatestVersion int `mapstructure:"max_concurrency_init_fetch_latest_version"`

// Max concurrent request for downloading every specific version of the vendor list from its first version to its latest version
// Max concurrent request for downloading every specific version of the vendor list from its first version to its latest version.
// If it is 0 or negative, then means there is no limit for the max concurrency.
MaxConcurrencyInitFetchSpecificVersion int `mapstructure:"max_concurrency_init_fetch_specific_version"`
}

Expand Down
9 changes: 7 additions & 2 deletions gdpr/vendorlist-fetching.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,13 @@ func preloadCache(ctx context.Context, client *http.Client, urlMaker func(uint16
var wgLatestVersion errgroup.Group
var wgSpecificVersion errgroup.Group

wgLatestVersion.SetLimit(conf.MaxConcurrencyInitFetchLatestVersion)
wgSpecificVersion.SetLimit(conf.MaxConcurrencyInitFetchSpecificVersion)
if conf.MaxConcurrencyInitFetchLatestVersion > 0 {
wgLatestVersion.SetLimit(conf.MaxConcurrencyInitFetchLatestVersion)
}

if conf.MaxConcurrencyInitFetchSpecificVersion > 0 {
wgSpecificVersion.SetLimit(conf.MaxConcurrencyInitFetchSpecificVersion)
}

tsStart := time.Now() // For logging how long this takes
for _, v := range versions {
Expand Down
4 changes: 4 additions & 0 deletions gdpr/vendorlist-fetching_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,5 +411,9 @@ func testConfig() config.GDPR {
InitVendorlistFetch: 60 * 1000,
ActiveVendorlistFetch: 1000 * 5,
},
VendorListFetcher: config.VendorListFetcher{
MaxConcurrencyInitFetchLatestVersion: 2,
MaxConcurrencyInitFetchSpecificVersion: 2,
},
}
}
4 changes: 2 additions & 2 deletions sample/001_banner/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ status_response: "ok" # default response string for /status endpoint
gdpr:
default_value: "0" # disable gdpr, explicitly specifying a default value is a requirement in prebid server config
vendorlist_fetcher:
max_concurrency_init_fetch_latest_version: 1
max_concurrency_init_fetch_specific_version: 1
max_concurrency_init_fetch_latest_version: 2
max_concurrency_init_fetch_specific_version: 20
timeouts_ms:
init_vendorlist_fetches: 30000
active_vendorlist_fetch: 30000
Expand Down

0 comments on commit 0a5b937

Please sign in to comment.