From 0a5b9377749077a331bce2816da20c72216f4464 Mon Sep 17 00:00:00 2001 From: Zhongshi Xi Date: Mon, 21 Oct 2024 23:05:45 -0400 Subject: [PATCH] fix test;add more comments --- config/config.go | 6 ++++-- gdpr/vendorlist-fetching.go | 9 +++++++-- gdpr/vendorlist-fetching_test.go | 4 ++++ sample/001_banner/app.yaml | 4 ++-- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/config/config.go b/config/config.go index 7749b75c186..3743646a81e 100644 --- a/config/config.go +++ b/config/config.go @@ -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"` } diff --git a/gdpr/vendorlist-fetching.go b/gdpr/vendorlist-fetching.go index 4c461852661..d05b9081af4 100644 --- a/gdpr/vendorlist-fetching.go +++ b/gdpr/vendorlist-fetching.go @@ -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 { diff --git a/gdpr/vendorlist-fetching_test.go b/gdpr/vendorlist-fetching_test.go index ebccb935244..f223e9ac837 100644 --- a/gdpr/vendorlist-fetching_test.go +++ b/gdpr/vendorlist-fetching_test.go @@ -411,5 +411,9 @@ func testConfig() config.GDPR { InitVendorlistFetch: 60 * 1000, ActiveVendorlistFetch: 1000 * 5, }, + VendorListFetcher: config.VendorListFetcher{ + MaxConcurrencyInitFetchLatestVersion: 2, + MaxConcurrencyInitFetchSpecificVersion: 2, + }, } } diff --git a/sample/001_banner/app.yaml b/sample/001_banner/app.yaml index c293a7b33ca..36b36455def 100644 --- a/sample/001_banner/app.yaml +++ b/sample/001_banner/app.yaml @@ -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