-
Notifications
You must be signed in to change notification settings - Fork 735
/
config.go
1323 lines (1176 loc) · 59 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package config
import (
"encoding/json"
"errors"
"fmt"
"net/url"
"reflect"
"strings"
"time"
"github.com/golang/glog"
"github.com/prebid/go-gdpr/consentconstants"
"github.com/prebid/openrtb/v20/openrtb2"
"github.com/prebid/prebid-server/v2/errortypes"
"github.com/prebid/prebid-server/v2/openrtb_ext"
"github.com/prebid/prebid-server/v2/util/jsonutil"
"github.com/spf13/viper"
)
// Configuration specifies the static application config.
type Configuration struct {
ExternalURL string `mapstructure:"external_url"`
Host string `mapstructure:"host"`
Port int `mapstructure:"port"`
UnixSocketEnable bool `mapstructure:"unix_socket_enable"`
UnixSocketName string `mapstructure:"unix_socket_name"`
Client HTTPClient `mapstructure:"http_client"`
CacheClient HTTPClient `mapstructure:"http_client_cache"`
AdminPort int `mapstructure:"admin_port"`
Compression Compression `mapstructure:"compression"`
// GarbageCollectorThreshold allocates virtual memory (in bytes) which is not used by PBS but
// serves as a hack to trigger the garbage collector only when the heap reaches at least this size.
// More info: https://github.com/golang/go/issues/48409
GarbageCollectorThreshold int `mapstructure:"garbage_collector_threshold"`
// StatusResponse is the string which will be returned by the /status endpoint when things are OK.
// If empty, it will return a 204 with no content.
StatusResponse string `mapstructure:"status_response"`
AuctionTimeouts AuctionTimeouts `mapstructure:"auction_timeouts_ms"`
TmaxAdjustments TmaxAdjustments `mapstructure:"tmax_adjustments"`
CacheURL Cache `mapstructure:"cache"`
ExtCacheURL ExternalCache `mapstructure:"external_cache"`
RecaptchaSecret string `mapstructure:"recaptcha_secret"`
HostCookie HostCookie `mapstructure:"host_cookie"`
Metrics Metrics `mapstructure:"metrics"`
StoredRequests StoredRequests `mapstructure:"stored_requests"`
StoredRequestsAMP StoredRequests `mapstructure:"stored_amp_req"`
CategoryMapping StoredRequests `mapstructure:"category_mapping"`
VTrack VTrack `mapstructure:"vtrack"`
Event Event `mapstructure:"event"`
Accounts StoredRequests `mapstructure:"accounts"`
UserSync UserSync `mapstructure:"user_sync"`
// Note that StoredVideo refers to stored video requests, and has nothing to do with caching video creatives.
StoredVideo StoredRequests `mapstructure:"stored_video_req"`
StoredResponses StoredRequests `mapstructure:"stored_responses"`
MaxRequestSize int64 `mapstructure:"max_request_size"`
Analytics Analytics `mapstructure:"analytics"`
AMPTimeoutAdjustment int64 `mapstructure:"amp_timeout_adjustment_ms"`
GDPR GDPR `mapstructure:"gdpr"`
CCPA CCPA `mapstructure:"ccpa"`
LMT LMT `mapstructure:"lmt"`
CurrencyConverter CurrencyConverter `mapstructure:"currency_converter"`
DefReqConfig DefReqConfig `mapstructure:"default_request"`
VideoStoredRequestRequired bool `mapstructure:"video_stored_request_required"`
// Array of blacklisted apps that is used to create the hash table BlacklistedAppMap so App.ID's can be instantly accessed.
BlacklistedApps []string `mapstructure:"blacklisted_apps,flow"`
BlacklistedAppMap map[string]bool
// Is publisher/account ID required to be submitted in the OpenRTB2 request
AccountRequired bool `mapstructure:"account_required"`
// AccountDefaults defines default settings for valid accounts that are partially defined
// and provides a way to set global settings that can be overridden at account level.
AccountDefaults Account `mapstructure:"account_defaults"`
// accountDefaultsJSON is the internal serialized form of AccountDefaults used for json merge
accountDefaultsJSON json.RawMessage
// Local private file containing SSL certificates
PemCertsFile string `mapstructure:"certificates_file"`
// Custom headers to handle request timeouts from queueing infrastructure
RequestTimeoutHeaders RequestTimeoutHeaders `mapstructure:"request_timeout_headers"`
// Debug/logging flags go here
Debug Debug `mapstructure:"debug"`
// RequestValidation specifies the request validation options.
RequestValidation RequestValidation `mapstructure:"request_validation"`
// When true, PBS will assign a randomly generated UUID to req.Source.TID if it is empty
AutoGenSourceTID bool `mapstructure:"auto_gen_source_tid"`
//When true, new bid id will be generated in seatbid[].bid[].ext.prebid.bidid and used in event urls instead
GenerateBidID bool `mapstructure:"generate_bid_id"`
// GenerateRequestID overrides the bidrequest.id in an AMP Request or an App Stored Request with a generated UUID if set to true. The default is false.
GenerateRequestID bool `mapstructure:"generate_request_id"`
HostSChainNode *openrtb2.SupplyChainNode `mapstructure:"host_schain_node"`
// Experiment configures non-production ready features.
Experiment Experiment `mapstructure:"experiment"`
DataCenter string `mapstructure:"datacenter"`
// BidderInfos supports adapter overrides in extra configs like pbs.json, pbs.yaml, etc.
// Refers to main.go `configFileName` constant
BidderInfos BidderInfos `mapstructure:"adapters"`
// Hooks provides a way to specify hook execution plan for specific endpoints and stages
Hooks Hooks `mapstructure:"hooks"`
Validations Validations `mapstructure:"validations"`
PriceFloors PriceFloors `mapstructure:"price_floors"`
}
type PriceFloors struct {
Enabled bool `mapstructure:"enabled"`
Fetcher PriceFloorFetcher `mapstructure:"fetcher"`
}
type PriceFloorFetcher struct {
HttpClient HTTPClient `mapstructure:"http_client"`
CacheSize int `mapstructure:"cache_size_mb"`
Worker int `mapstructure:"worker"`
Capacity int `mapstructure:"capacity"`
MaxRetries int `mapstructure:"max_retries"`
}
const MIN_COOKIE_SIZE_BYTES = 500
type HTTPClient struct {
MaxConnsPerHost int `mapstructure:"max_connections_per_host"`
MaxIdleConns int `mapstructure:"max_idle_connections"`
MaxIdleConnsPerHost int `mapstructure:"max_idle_connections_per_host"`
IdleConnTimeout int `mapstructure:"idle_connection_timeout_seconds"`
}
func (cfg *Configuration) validate(v *viper.Viper) []error {
var errs []error
errs = cfg.AuctionTimeouts.validate(errs)
errs = cfg.StoredRequests.validate(errs)
errs = cfg.StoredRequestsAMP.validate(errs)
errs = cfg.Accounts.validate(errs)
errs = cfg.CategoryMapping.validate(errs)
errs = cfg.StoredVideo.validate(errs)
errs = cfg.Metrics.validate(errs)
if cfg.MaxRequestSize < 0 {
errs = append(errs, fmt.Errorf("cfg.max_request_size must be >= 0. Got %d", cfg.MaxRequestSize))
}
errs = cfg.GDPR.validate(v, errs)
errs = cfg.CurrencyConverter.validate(errs)
errs = cfg.Debug.validate(errs)
errs = cfg.ExtCacheURL.validate(errs)
errs = cfg.AccountDefaults.PriceFloors.validate(errs)
if cfg.AccountDefaults.Disabled {
glog.Warning(`With account_defaults.disabled=true, host-defined accounts must exist and have "disabled":false. All other requests will be rejected.`)
}
if cfg.AccountDefaults.Events.Enabled {
glog.Warning(`account_defaults.events has no effect as the feature is under development.`)
}
errs = cfg.Experiment.validate(errs)
errs = cfg.BidderInfos.validate(errs)
errs = cfg.AccountDefaults.Privacy.IPv6Config.Validate(errs)
errs = cfg.AccountDefaults.Privacy.IPv4Config.Validate(errs)
return errs
}
type AuctionTimeouts struct {
// The default timeout is used if the user's request didn't define one. Use 0 if there's no default.
Default uint64 `mapstructure:"default"`
// The max timeout is used as an absolute cap, to prevent excessively long ones. Use 0 for no cap
Max uint64 `mapstructure:"max"`
}
func (cfg *AuctionTimeouts) validate(errs []error) []error {
if cfg.Max < cfg.Default {
errs = append(errs, fmt.Errorf("auction_timeouts_ms.max cannot be less than auction_timeouts_ms.default. max=%d, default=%d", cfg.Max, cfg.Default))
}
return errs
}
func (data *ExternalCache) validate(errs []error) []error {
if data.Host == "" && data.Path == "" {
// Both host and path can be blank. No further validation needed
return errs
}
if data.Scheme != "" && data.Scheme != "http" && data.Scheme != "https" {
return append(errs, errors.New("External cache Scheme must be http or https if specified"))
}
// Either host or path or both not empty, validate.
if data.Host == "" && data.Path != "" || data.Host != "" && data.Path == "" {
return append(errs, errors.New("External cache Host and Path must both be specified"))
}
if strings.HasSuffix(data.Host, "/") {
return append(errs, errors.New(fmt.Sprintf("External cache Host '%s' must not end with a path separator", data.Host)))
}
if strings.Contains(data.Host, "://") {
return append(errs, errors.New(fmt.Sprintf("External cache Host must not specify a protocol. '%s'", data.Host)))
}
if !strings.HasPrefix(data.Path, "/") {
return append(errs, errors.New(fmt.Sprintf("External cache Path '%s' must begin with a path separator", data.Path)))
}
urlObj, err := url.Parse("https://" + data.Host + data.Path)
if err != nil {
return append(errs, errors.New(fmt.Sprintf("External cache Path validation error: %s ", err.Error())))
}
if urlObj.Host != data.Host {
return append(errs, errors.New(fmt.Sprintf("External cache Host '%s' is invalid", data.Host)))
}
if urlObj.Path != data.Path {
return append(errs, errors.New("External cache Path is invalid"))
}
return errs
}
// LimitAuctionTimeout returns the min of requested or cfg.MaxAuctionTimeout.
// Both values treat "0" as "infinite".
func (cfg *AuctionTimeouts) LimitAuctionTimeout(requested time.Duration) time.Duration {
if requested == 0 && cfg.Default != 0 {
return time.Duration(cfg.Default) * time.Millisecond
}
if cfg.Max > 0 {
maxTimeout := time.Duration(cfg.Max) * time.Millisecond
if requested == 0 || requested > maxTimeout {
return maxTimeout
}
}
return requested
}
// Privacy is a grouping of privacy related configs to assist in dependency injection.
type Privacy struct {
CCPA CCPA
GDPR GDPR
LMT LMT
}
type GDPR struct {
Enabled bool `mapstructure:"enabled"`
HostVendorID int `mapstructure:"host_vendor_id"`
DefaultValue string `mapstructure:"default_value"`
Timeouts GDPRTimeouts `mapstructure:"timeouts_ms"`
NonStandardPublishers []string `mapstructure:"non_standard_publishers,flow"`
NonStandardPublisherMap map[string]struct{}
TCF2 TCF2 `mapstructure:"tcf2"`
AMPException bool `mapstructure:"amp_exception"` // Deprecated: Use account-level GDPR settings (gdpr.integration_enabled.amp) instead
// EEACountries (EEA = European Economic Area) are a list of countries where we should assume GDPR applies.
// If the gdpr flag is unset in a request, but geo.country is set, we will assume GDPR applies if and only
// if the country matches one on this list. If both the GDPR flag and country are not set, we default
// to DefaultValue
EEACountries []string `mapstructure:"eea_countries"`
EEACountriesMap map[string]struct{}
}
func (cfg *GDPR) validate(v *viper.Viper, errs []error) []error {
if !v.IsSet("gdpr.default_value") {
errs = append(errs, fmt.Errorf("gdpr.default_value is required and must be specified"))
} else if cfg.DefaultValue != "0" && cfg.DefaultValue != "1" {
errs = append(errs, fmt.Errorf("gdpr.default_value must be 0 or 1"))
}
if cfg.HostVendorID < 0 || cfg.HostVendorID > 0xffff {
errs = append(errs, fmt.Errorf("gdpr.host_vendor_id must be in the range [0, %d]. Got %d", 0xffff, cfg.HostVendorID))
}
if cfg.HostVendorID == 0 {
glog.Warning("gdpr.host_vendor_id was not specified. Host company GDPR checks will be skipped.")
}
if cfg.AMPException == true {
errs = append(errs, fmt.Errorf("gdpr.amp_exception has been discontinued and must be removed from your config. If you need to disable GDPR for AMP, you may do so per-account (gdpr.integration_enabled.amp) or at the host level for the default account (account_defaults.gdpr.integration_enabled.amp)"))
}
return cfg.validatePurposes(errs)
}
func (cfg *GDPR) validatePurposes(errs []error) []error {
purposeConfigs := []TCF2Purpose{
cfg.TCF2.Purpose1,
cfg.TCF2.Purpose2,
cfg.TCF2.Purpose3,
cfg.TCF2.Purpose4,
cfg.TCF2.Purpose5,
cfg.TCF2.Purpose6,
cfg.TCF2.Purpose7,
cfg.TCF2.Purpose8,
cfg.TCF2.Purpose9,
cfg.TCF2.Purpose10,
}
for i := 0; i < len(purposeConfigs); i++ {
enforceAlgoValue := purposeConfigs[i].EnforceAlgo
enforceAlgoField := fmt.Sprintf("gdpr.tcf2.purpose%d.enforce_algo", (i + 1))
if enforceAlgoValue != TCF2EnforceAlgoFull && enforceAlgoValue != TCF2EnforceAlgoBasic {
errs = append(errs, fmt.Errorf("%s must be \"basic\" or \"full\". Got %s", enforceAlgoField, enforceAlgoValue))
}
}
return errs
}
type GDPRTimeouts struct {
InitVendorlistFetch int `mapstructure:"init_vendorlist_fetches"`
ActiveVendorlistFetch int `mapstructure:"active_vendorlist_fetch"`
}
func (t *GDPRTimeouts) InitTimeout() time.Duration {
return time.Duration(t.InitVendorlistFetch) * time.Millisecond
}
func (t *GDPRTimeouts) ActiveTimeout() time.Duration {
return time.Duration(t.ActiveVendorlistFetch) * time.Millisecond
}
const (
TCF2EnforceAlgoBasic = "basic"
TCF2EnforceAlgoFull = "full"
)
type TCF2EnforcementAlgo int
const (
TCF2UndefinedEnforcement TCF2EnforcementAlgo = iota
TCF2BasicEnforcement
TCF2FullEnforcement
)
// TCF2 defines the TCF2 specific configurations for GDPR
type TCF2 struct {
Enabled bool `mapstructure:"enabled"`
Purpose1 TCF2Purpose `mapstructure:"purpose1"`
Purpose2 TCF2Purpose `mapstructure:"purpose2"`
Purpose3 TCF2Purpose `mapstructure:"purpose3"`
Purpose4 TCF2Purpose `mapstructure:"purpose4"`
Purpose5 TCF2Purpose `mapstructure:"purpose5"`
Purpose6 TCF2Purpose `mapstructure:"purpose6"`
Purpose7 TCF2Purpose `mapstructure:"purpose7"`
Purpose8 TCF2Purpose `mapstructure:"purpose8"`
Purpose9 TCF2Purpose `mapstructure:"purpose9"`
Purpose10 TCF2Purpose `mapstructure:"purpose10"`
// Map of purpose configs for easy purpose lookup
PurposeConfigs map[consentconstants.Purpose]*TCF2Purpose
SpecialFeature1 TCF2SpecialFeature `mapstructure:"special_feature1"`
PurposeOneTreatment TCF2PurposeOneTreatment `mapstructure:"purpose_one_treatment"`
}
// ChannelEnabled checks if a given channel type is enabled. All channel types are considered either
// enabled or disabled based on the Enabled flag.
func (t *TCF2) ChannelEnabled(channelType ChannelType) bool {
return t.Enabled
}
// IsEnabled indicates if TCF2 is enabled
func (t *TCF2) IsEnabled() bool {
return t.Enabled
}
// PurposeEnforced checks if full enforcement is turned on for a given purpose. With full enforcement enabled, the
// GDPR full enforcement algorithm will execute for that purpose determining legal basis; otherwise it's skipped.
func (t *TCF2) PurposeEnforced(purpose consentconstants.Purpose) (enforce bool) {
if t.PurposeConfigs[purpose] == nil {
return false
}
return t.PurposeConfigs[purpose].EnforcePurpose
}
// PurposeEnforcementAlgo returns the default enforcement algorithm for a given purpose
func (t *TCF2) PurposeEnforcementAlgo(purpose consentconstants.Purpose) (enforcement TCF2EnforcementAlgo) {
if c, exists := t.PurposeConfigs[purpose]; exists {
return c.EnforceAlgoID
}
return TCF2FullEnforcement
}
// PurposeEnforcingVendors checks if enforcing vendors is turned on for a given purpose. With enforcing vendors
// enabled, the GDPR full enforcement algorithm considers the GVL when determining legal basis; otherwise it's skipped.
func (t *TCF2) PurposeEnforcingVendors(purpose consentconstants.Purpose) (enforce bool) {
if t.PurposeConfigs[purpose] == nil {
return false
}
return t.PurposeConfigs[purpose].EnforceVendors
}
// PurposeVendorExceptions returns the vendor exception map for a given purpose if it exists, otherwise it returns
// an empty map of vendor exceptions
func (t *TCF2) PurposeVendorExceptions(purpose consentconstants.Purpose) (vendorExceptions map[string]struct{}) {
c, exists := t.PurposeConfigs[purpose]
if exists && c.VendorExceptionMap != nil {
return c.VendorExceptionMap
}
return make(map[string]struct{}, 0)
}
// FeatureOneEnforced checks if special feature one is enforced. If it is enforced, PBS will determine whether geo
// information may be passed through in the bid request.
func (t *TCF2) FeatureOneEnforced() bool {
return t.SpecialFeature1.Enforce
}
// FeatureOneVendorException checks if the specified bidder is considered a vendor exception for special feature one.
// If a bidder is a vendor exception, PBS will bypass the pass geo calculation passing the geo information in the bid request.
func (t *TCF2) FeatureOneVendorException(bidder openrtb_ext.BidderName) bool {
if _, ok := t.SpecialFeature1.VendorExceptionMap[bidder]; ok {
return true
}
return false
}
// PurposeOneTreatmentEnabled checks if purpose one treatment is enabled.
func (t *TCF2) PurposeOneTreatmentEnabled() bool {
return t.PurposeOneTreatment.Enabled
}
// PurposeOneTreatmentAccessAllowed checks if purpose one treatment access is allowed.
func (t *TCF2) PurposeOneTreatmentAccessAllowed() bool {
return t.PurposeOneTreatment.AccessAllowed
}
// Making a purpose struct so purpose specific details can be added later.
type TCF2Purpose struct {
EnforceAlgo string `mapstructure:"enforce_algo"`
// Integer representation of enforcement algo for performance improvement on compares
EnforceAlgoID TCF2EnforcementAlgo
EnforcePurpose bool `mapstructure:"enforce_purpose"`
EnforceVendors bool `mapstructure:"enforce_vendors"`
// Array of vendor exceptions that is used to create the hash table VendorExceptionMap so vendor names can be instantly accessed
VendorExceptions []string `mapstructure:"vendor_exceptions"`
VendorExceptionMap map[string]struct{}
}
type TCF2SpecialFeature struct {
Enforce bool `mapstructure:"enforce"`
// Array of vendor exceptions that is used to create the hash table VendorExceptionMap so vendor names can be instantly accessed
VendorExceptions []openrtb_ext.BidderName `mapstructure:"vendor_exceptions"`
VendorExceptionMap map[openrtb_ext.BidderName]struct{}
}
type TCF2PurposeOneTreatment struct {
Enabled bool `mapstructure:"enabled"`
AccessAllowed bool `mapstructure:"access_allowed"`
}
type CCPA struct {
Enforce bool `mapstructure:"enforce"`
}
type LMT struct {
Enforce bool `mapstructure:"enforce"`
}
type Analytics struct {
File FileLogs `mapstructure:"file"`
Agma AgmaAnalytics `mapstructure:"agma"`
Pubstack Pubstack `mapstructure:"pubstack"`
}
type CurrencyConverter struct {
FetchURL string `mapstructure:"fetch_url"`
FetchIntervalSeconds int `mapstructure:"fetch_interval_seconds"`
StaleRatesSeconds int `mapstructure:"stale_rates_seconds"`
}
func (cfg *CurrencyConverter) validate(errs []error) []error {
if cfg.FetchIntervalSeconds < 0 {
errs = append(errs, fmt.Errorf("currency_converter.fetch_interval_seconds must be in the range [0, %d]. Got %d", 0xffff, cfg.FetchIntervalSeconds))
}
return errs
}
type AgmaAnalytics struct {
Enabled bool `mapstructure:"enabled"`
Endpoint AgmaAnalyticsHttpEndpoint `mapstructure:"endpoint"`
Buffers AgmaAnalyticsBuffer `mapstructure:"buffers"`
Accounts []AgmaAnalyticsAccount `mapstructure:"accounts"`
}
type AgmaAnalyticsHttpEndpoint struct {
Url string `mapstructure:"url"`
Timeout string `mapstructure:"timeout"`
Gzip bool `mapstructure:"gzip"`
}
type AgmaAnalyticsBuffer struct {
BufferSize string `mapstructure:"size"`
EventCount int `mapstructure:"count"`
Timeout string `mapstructure:"timeout"`
}
type AgmaAnalyticsAccount struct {
Code string `mapstructure:"code"`
PublisherId string `mapstructure:"publisher_id"`
SiteAppId string `mapstructure:"site_app_id"`
}
// FileLogs Corresponding config for FileLogger as a PBS Analytics Module
type FileLogs struct {
Filename string `mapstructure:"filename"`
}
type Pubstack struct {
Enabled bool `mapstructure:"enabled"`
ScopeId string `mapstructure:"scopeid"`
IntakeUrl string `mapstructure:"endpoint"`
Buffers PubstackBuffer `mapstructure:"buffers"`
ConfRefresh string `mapstructure:"configuration_refresh_delay"`
}
type PubstackBuffer struct {
BufferSize string `mapstructure:"size"`
EventCount int `mapstructure:"count"`
Timeout string `mapstructure:"timeout"`
}
type VTrack struct {
TimeoutMS int64 `mapstructure:"timeout_ms"`
AllowUnknownBidder bool `mapstructure:"allow_unknown_bidder"`
Enabled bool `mapstructure:"enabled"`
}
type Event struct {
TimeoutMS int64 `mapstructure:"timeout_ms"`
}
type HostCookie struct {
Domain string `mapstructure:"domain"`
Family string `mapstructure:"family"`
CookieName string `mapstructure:"cookie_name"`
OptOutURL string `mapstructure:"opt_out_url"`
OptInURL string `mapstructure:"opt_in_url"`
MaxCookieSizeBytes int `mapstructure:"max_cookie_size_bytes"`
OptOutCookie Cookie `mapstructure:"optout_cookie"`
// Cookie timeout in days
TTL int64 `mapstructure:"ttl_days"`
}
func (cfg *HostCookie) TTLDuration() time.Duration {
return time.Duration(cfg.TTL) * time.Hour * 24
}
type RequestTimeoutHeaders struct {
RequestTimeInQueue string `mapstructure:"request_time_in_queue"`
RequestTimeoutInQueue string `mapstructure:"request_timeout_in_queue"`
}
type Metrics struct {
Influxdb InfluxMetrics `mapstructure:"influxdb"`
Prometheus PrometheusMetrics `mapstructure:"prometheus"`
Disabled DisabledMetrics `mapstructure:"disabled_metrics"`
}
type DisabledMetrics struct {
// True if we want to stop collecting account-to-adapter metrics
AccountAdapterDetails bool `mapstructure:"account_adapter_details"`
// True if we want to stop collecting account debug request metrics
AccountDebug bool `mapstructure:"account_debug"`
// True if we want to stop collecting account stored respponses metrics
AccountStoredResponses bool `mapstructure:"account_stored_responses"`
// True if we don't want to collect metrics about the connections prebid
// server establishes with bidder servers such as the number of connections
// that were created or reused.
AdapterConnectionMetrics bool `mapstructure:"adapter_connections_metrics"`
// True if we don't want to collect the per adapter GDPR request blocked metric
AdapterGDPRRequestBlocked bool `mapstructure:"adapter_gdpr_request_blocked"`
// True if we want to stop collecting account modules metrics
AccountModulesMetrics bool `mapstructure:"account_modules_metrics"`
}
func (cfg *Metrics) validate(errs []error) []error {
return cfg.Prometheus.validate(errs)
}
type InfluxMetrics struct {
Host string `mapstructure:"host"`
Database string `mapstructure:"database"`
Measurement string `mapstructure:"measurement"`
Username string `mapstructure:"username"`
Password string `mapstructure:"password"`
AlignTimestamps bool `mapstructure:"align_timestamps"`
MetricSendInterval int `mapstructure:"metric_send_interval"`
}
type PrometheusMetrics struct {
Port int `mapstructure:"port"`
Namespace string `mapstructure:"namespace"`
Subsystem string `mapstructure:"subsystem"`
TimeoutMillisRaw int `mapstructure:"timeout_ms"`
}
func (cfg *PrometheusMetrics) validate(errs []error) []error {
if cfg.Port > 0 && cfg.TimeoutMillisRaw <= 0 {
errs = append(errs, fmt.Errorf("metrics.prometheus.timeout_ms must be positive if metrics.prometheus.port is defined. Got timeout=%d and port=%d", cfg.TimeoutMillisRaw, cfg.Port))
}
return errs
}
func (m *PrometheusMetrics) Timeout() time.Duration {
return time.Duration(m.TimeoutMillisRaw) * time.Millisecond
}
// ExternalCache configures the externally accessible cache url.
type ExternalCache struct {
Scheme string `mapstructure:"scheme"`
Host string `mapstructure:"host"`
Path string `mapstructure:"path"`
}
// Cache configures the url used internally by Prebid Server to communicate with Prebid Cache.
type Cache struct {
Scheme string `mapstructure:"scheme"`
Host string `mapstructure:"host"`
Query string `mapstructure:"query"`
// A static timeout here is not ideal. This is a hack because we have some aggressive timelines for OpenRTB support.
// This value specifies how much time the prebid server host expects a call to prebid cache to take.
//
// OpenRTB allows the caller to specify the auction timeout. Prebid Server will subtract _this_ amount of time
// from the timeout it gives demand sources to respond.
//
// In reality, the cache response time will probably fluctuate with the traffic over time. Someday,
// this should be replaced by code which tracks the response time of recent cache calls and
// adjusts the time dynamically.
ExpectedTimeMillis int `mapstructure:"expected_millis"`
DefaultTTLs DefaultTTLs `mapstructure:"default_ttl_seconds"`
}
// Default TTLs to use to cache bids for different types of imps.
type DefaultTTLs struct {
Banner int `mapstructure:"banner"`
Video int `mapstructure:"video"`
Native int `mapstructure:"native"`
Audio int `mapstructure:"audio"`
}
type Cookie struct {
Name string `mapstructure:"name"`
Value string `mapstructure:"value"`
}
// AliasConfig will define the various source(s) or the default aliases
// Currently only filesystem is supported, but keeping the config structure
type DefReqConfig struct {
Type string `mapstructure:"type"`
FileSystem DefReqFiles `mapstructure:"file"`
AliasInfo bool `mapstructure:"alias_info"`
}
type DefReqFiles struct {
FileName string `mapstructure:"name"`
}
type Debug struct {
TimeoutNotification TimeoutNotification `mapstructure:"timeout_notification"`
OverrideToken string `mapstructure:"override_token"`
}
type Server struct {
ExternalUrl string
GvlID int
DataCenter string
}
func (server *Server) Empty() bool {
return server == nil || (server.DataCenter == "" && server.ExternalUrl == "" && server.GvlID == 0)
}
func (cfg *Debug) validate(errs []error) []error {
return cfg.TimeoutNotification.validate(errs)
}
type TimeoutNotification struct {
// Log timeout notifications in the application log
Log bool `mapstructure:"log"`
// Fraction of notifications to log
SamplingRate float32 `mapstructure:"sampling_rate"`
// Only log failures
FailOnly bool `mapstructure:"fail_only"`
}
type Validations struct {
BannerCreativeMaxSize string `mapstructure:"banner_creative_max_size" json:"banner_creative_max_size"`
SecureMarkup string `mapstructure:"secure_markup" json:"secure_markup"`
MaxCreativeWidth int64 `mapstructure:"max_creative_width" json:"max_creative_width"`
MaxCreativeHeight int64 `mapstructure:"max_creative_height" json:"max_creative_height"`
}
const (
ValidationEnforce string = "enforce"
ValidationWarn string = "warn"
ValidationSkip string = "skip"
)
func (host *Validations) SetBannerCreativeMaxSize(account Validations) {
if len(account.BannerCreativeMaxSize) > 0 {
host.BannerCreativeMaxSize = account.BannerCreativeMaxSize
}
}
func (cfg *TimeoutNotification) validate(errs []error) []error {
if cfg.SamplingRate < 0.0 || cfg.SamplingRate > 1.0 {
errs = append(errs, fmt.Errorf("debug.timeout_notification.sampling_rate must be positive and not greater than 1.0. Got %f", cfg.SamplingRate))
}
return errs
}
// New uses viper to get our server configurations.
func New(v *viper.Viper, bidderInfos BidderInfos, normalizeBidderName func(string) (openrtb_ext.BidderName, bool)) (*Configuration, error) {
var c Configuration
if err := v.Unmarshal(&c); err != nil {
return nil, fmt.Errorf("viper failed to unmarshal app config: %v", err)
}
if err := c.RequestValidation.Parse(); err != nil {
return nil, err
}
if err := isValidCookieSize(c.HostCookie.MaxCookieSizeBytes); err != nil {
glog.Fatal(fmt.Printf("Max cookie size %d cannot be less than %d \n", c.HostCookie.MaxCookieSizeBytes, MIN_COOKIE_SIZE_BYTES))
return nil, err
}
// Update account defaults and generate base json for patch
c.AccountDefaults.CacheTTL = c.CacheURL.DefaultTTLs // comment this out to set explicitly in config
if err := c.MarshalAccountDefaults(); err != nil {
return nil, err
}
// To look for a request's publisher_id in the NonStandardPublishers list in
// O(1) time, we fill this hash table located in the NonStandardPublisherMap field of GDPR
var s struct{}
c.GDPR.NonStandardPublisherMap = make(map[string]struct{})
for i := 0; i < len(c.GDPR.NonStandardPublishers); i++ {
c.GDPR.NonStandardPublisherMap[c.GDPR.NonStandardPublishers[i]] = s
}
c.GDPR.EEACountriesMap = make(map[string]struct{}, len(c.GDPR.EEACountries))
for _, v := range c.GDPR.EEACountries {
c.GDPR.EEACountriesMap[v] = s
}
// for each purpose we capture a reference to the purpose config in a map for easy purpose config lookup
c.GDPR.TCF2.PurposeConfigs = map[consentconstants.Purpose]*TCF2Purpose{
1: &c.GDPR.TCF2.Purpose1,
2: &c.GDPR.TCF2.Purpose2,
3: &c.GDPR.TCF2.Purpose3,
4: &c.GDPR.TCF2.Purpose4,
5: &c.GDPR.TCF2.Purpose5,
6: &c.GDPR.TCF2.Purpose6,
7: &c.GDPR.TCF2.Purpose7,
8: &c.GDPR.TCF2.Purpose8,
9: &c.GDPR.TCF2.Purpose9,
10: &c.GDPR.TCF2.Purpose10,
}
// As an alternative to performing several string compares per request, we set the integer representation of
// the enforcement algorithm on each purpose config
for _, pc := range c.GDPR.TCF2.PurposeConfigs {
if pc.EnforceAlgo == TCF2EnforceAlgoBasic {
pc.EnforceAlgoID = TCF2BasicEnforcement
} else {
pc.EnforceAlgoID = TCF2FullEnforcement
}
}
// To look for a purpose's vendor exceptions in O(1) time, for each purpose we fill this hash table with bidders/analytics
// adapters located in the VendorExceptions field of the GDPR.TCF2.PurposeX struct defined in this file
for _, pc := range c.GDPR.TCF2.PurposeConfigs {
pc.VendorExceptionMap = make(map[string]struct{})
for v := 0; v < len(pc.VendorExceptions); v++ {
adapterName := pc.VendorExceptions[v]
pc.VendorExceptionMap[adapterName] = struct{}{}
}
}
// To look for a special feature's vendor exceptions in O(1) time, we fill this hash table with bidders located in the
// VendorExceptions field of the GDPR.TCF2.SpecialFeature1 struct defined in this file
c.GDPR.TCF2.SpecialFeature1.VendorExceptionMap = make(map[openrtb_ext.BidderName]struct{})
for v := 0; v < len(c.GDPR.TCF2.SpecialFeature1.VendorExceptions); v++ {
bidderName := c.GDPR.TCF2.SpecialFeature1.VendorExceptions[v]
c.GDPR.TCF2.SpecialFeature1.VendorExceptionMap[bidderName] = struct{}{}
}
// To look for a request's app_id in O(1) time, we fill this hash table located in the
// the BlacklistedApps field of the Configuration struct defined in this file
c.BlacklistedAppMap = make(map[string]bool)
for i := 0; i < len(c.BlacklistedApps); i++ {
c.BlacklistedAppMap[c.BlacklistedApps[i]] = true
}
// Migrate combo stored request config to separate stored_reqs and amp stored_reqs configs.
resolvedStoredRequestsConfig(&c)
configBidderInfosWithNillableFields, err := setConfigBidderInfoNillableFields(v, c.BidderInfos)
if err != nil {
return nil, err
}
mergedBidderInfos, err := applyBidderInfoConfigOverrides(configBidderInfosWithNillableFields, bidderInfos, normalizeBidderName)
if err != nil {
return nil, err
}
c.BidderInfos = mergedBidderInfos
glog.Info("Logging the resolved configuration:")
logGeneral(reflect.ValueOf(c), " \t")
if errs := c.validate(v); len(errs) > 0 {
return &c, errortypes.NewAggregateError("validation errors", errs)
}
return &c, nil
}
type bidderInfoNillableFields struct {
Disabled *bool `yaml:"disabled" mapstructure:"disabled"`
ModifyingVastXmlAllowed *bool `yaml:"modifyingVastXmlAllowed" mapstructure:"modifyingVastXmlAllowed"`
}
type nillableFieldBidderInfos map[string]nillableFieldBidderInfo
type nillableFieldBidderInfo struct {
nillableFields bidderInfoNillableFields
bidderInfo BidderInfo
}
func setConfigBidderInfoNillableFields(v *viper.Viper, bidderInfos BidderInfos) (nillableFieldBidderInfos, error) {
if len(bidderInfos) == 0 || v == nil {
return nil, nil
}
infos := make(nillableFieldBidderInfos, len(bidderInfos))
for bidderName, bidderInfo := range bidderInfos {
info := nillableFieldBidderInfo{bidderInfo: bidderInfo}
if err := v.UnmarshalKey("adapters."+bidderName+".disabled", &info.nillableFields.Disabled); err != nil {
return nil, fmt.Errorf("viper failed to unmarshal bidder config disabled: %v", err)
}
if err := v.UnmarshalKey("adapters."+bidderName+".modifyingvastxmlallowed", &info.nillableFields.ModifyingVastXmlAllowed); err != nil {
return nil, fmt.Errorf("viper failed to unmarshal bidder config modifyingvastxmlallowed: %v", err)
}
infos[bidderName] = info
}
return infos, nil
}
// MarshalAccountDefaults compiles AccountDefaults into the JSON format used for merge patch
func (cfg *Configuration) MarshalAccountDefaults() error {
var err error
if cfg.accountDefaultsJSON, err = jsonutil.Marshal(cfg.AccountDefaults); err != nil {
glog.Warningf("converting %+v to json: %v", cfg.AccountDefaults, err)
}
return err
}
// AccountDefaultsJSON returns the precompiled JSON form of account_defaults
func (cfg *Configuration) AccountDefaultsJSON() json.RawMessage {
return cfg.accountDefaultsJSON
}
// GetBaseURL allows for protocol relative URL if scheme is empty
func (cfg *Cache) GetBaseURL() string {
cfg.Scheme = strings.ToLower(cfg.Scheme)
if strings.Contains(cfg.Scheme, "https") {
return fmt.Sprintf("https://%s", cfg.Host)
}
if strings.Contains(cfg.Scheme, "http") {
return fmt.Sprintf("http://%s", cfg.Host)
}
return fmt.Sprintf("//%s", cfg.Host)
}
func (cfg *Configuration) GetCachedAssetURL(uuid string) string {
return fmt.Sprintf("%s/cache?%s", cfg.CacheURL.GetBaseURL(), strings.Replace(cfg.CacheURL.Query, "%PBS_CACHE_UUID%", uuid, 1))
}
// Set the default config values for the viper object we are using.
func SetupViper(v *viper.Viper, filename string, bidderInfos BidderInfos) {
if filename != "" {
v.SetConfigName(filename)
v.AddConfigPath(".")
v.AddConfigPath("/etc/config")
}
// Fixes #475: Some defaults will be set just so they are accessible via environment variables
// (basically so viper knows they exist)
v.SetDefault("external_url", "http://localhost:8000")
v.SetDefault("host", "")
v.SetDefault("port", 8000)
v.SetDefault("unix_socket_enable", false) // boolean which decide if the socket-server will be started.
v.SetDefault("unix_socket_name", "prebid-server.sock") // path of the socket's file which must be listened.
v.SetDefault("admin_port", 6060)
v.SetDefault("garbage_collector_threshold", 0)
v.SetDefault("status_response", "")
v.SetDefault("datacenter", "")
v.SetDefault("auction_timeouts_ms.default", 0)
v.SetDefault("auction_timeouts_ms.max", 0)
v.SetDefault("cache.scheme", "")
v.SetDefault("cache.host", "")
v.SetDefault("cache.query", "")
v.SetDefault("cache.expected_millis", 10)
v.SetDefault("cache.default_ttl_seconds.banner", 0)
v.SetDefault("cache.default_ttl_seconds.video", 0)
v.SetDefault("cache.default_ttl_seconds.native", 0)
v.SetDefault("cache.default_ttl_seconds.audio", 0)
v.SetDefault("external_cache.scheme", "")
v.SetDefault("external_cache.host", "")
v.SetDefault("external_cache.path", "")
v.SetDefault("recaptcha_secret", "")
v.SetDefault("host_cookie.domain", "")
v.SetDefault("host_cookie.family", "")
v.SetDefault("host_cookie.cookie_name", "")
v.SetDefault("host_cookie.opt_out_url", "")
v.SetDefault("host_cookie.opt_in_url", "")
v.SetDefault("host_cookie.optout_cookie.name", "")
v.SetDefault("host_cookie.value", "")
v.SetDefault("host_cookie.ttl_days", 90)
v.SetDefault("host_cookie.max_cookie_size_bytes", 0)
v.SetDefault("host_schain_node", nil)
v.SetDefault("validations.banner_creative_max_size", ValidationSkip)
v.SetDefault("validations.secure_markup", ValidationSkip)
v.SetDefault("validations.max_creative_size.height", 0)
v.SetDefault("validations.max_creative_size.width", 0)
v.SetDefault("http_client.max_connections_per_host", 0) // unlimited
v.SetDefault("http_client.max_idle_connections", 400)
v.SetDefault("http_client.max_idle_connections_per_host", 10)
v.SetDefault("http_client.idle_connection_timeout_seconds", 60)
v.SetDefault("http_client_cache.max_connections_per_host", 0) // unlimited
v.SetDefault("http_client_cache.max_idle_connections", 10)
v.SetDefault("http_client_cache.max_idle_connections_per_host", 2)
v.SetDefault("http_client_cache.idle_connection_timeout_seconds", 60)
// no metrics configured by default (metrics{host|database|username|password})
v.SetDefault("metrics.disabled_metrics.account_adapter_details", false)
v.SetDefault("metrics.disabled_metrics.account_debug", true)
v.SetDefault("metrics.disabled_metrics.account_stored_responses", true)
v.SetDefault("metrics.disabled_metrics.adapter_connections_metrics", true)
v.SetDefault("metrics.disabled_metrics.adapter_gdpr_request_blocked", false)
v.SetDefault("metrics.influxdb.host", "")
v.SetDefault("metrics.influxdb.database", "")
v.SetDefault("metrics.influxdb.measurement", "")
v.SetDefault("metrics.influxdb.username", "")
v.SetDefault("metrics.influxdb.password", "")
v.SetDefault("metrics.influxdb.align_timestamps", false)
v.SetDefault("metrics.influxdb.metric_send_interval", 20)
v.SetDefault("metrics.prometheus.port", 0)
v.SetDefault("metrics.prometheus.namespace", "")
v.SetDefault("metrics.prometheus.subsystem", "")
v.SetDefault("metrics.prometheus.timeout_ms", 10000)
v.SetDefault("category_mapping.filesystem.enabled", true)
v.SetDefault("category_mapping.filesystem.directorypath", "./static/category-mapping")
v.SetDefault("category_mapping.http.endpoint", "")
v.SetDefault("stored_requests.database.connection.driver", "")
v.SetDefault("stored_requests.database.connection.dbname", "")
v.SetDefault("stored_requests.database.connection.host", "")
v.SetDefault("stored_requests.database.connection.port", 0)
v.SetDefault("stored_requests.database.connection.user", "")
v.SetDefault("stored_requests.database.connection.password", "")
v.SetDefault("stored_requests.database.connection.query_string", "")
v.SetDefault("stored_requests.database.connection.tls.root_cert", "")
v.SetDefault("stored_requests.database.connection.tls.client_cert", "")
v.SetDefault("stored_requests.database.connection.tls.client_key", "")
v.SetDefault("stored_requests.database.fetcher.query", "")
v.SetDefault("stored_requests.database.fetcher.amp_query", "")
v.SetDefault("stored_requests.database.initialize_caches.timeout_ms", 0)
v.SetDefault("stored_requests.database.initialize_caches.query", "")
v.SetDefault("stored_requests.database.initialize_caches.amp_query", "")
v.SetDefault("stored_requests.database.poll_for_updates.refresh_rate_seconds", 0)
v.SetDefault("stored_requests.database.poll_for_updates.timeout_ms", 0)
v.SetDefault("stored_requests.database.poll_for_updates.query", "")
v.SetDefault("stored_requests.database.poll_for_updates.amp_query", "")
v.SetDefault("stored_requests.filesystem.enabled", false)
v.SetDefault("stored_requests.filesystem.directorypath", "./stored_requests/data/by_id")
v.SetDefault("stored_requests.directorypath", "./stored_requests/data/by_id")
v.SetDefault("stored_requests.http.endpoint", "")
v.SetDefault("stored_requests.http.amp_endpoint", "")
v.SetDefault("stored_requests.in_memory_cache.type", "none")
v.SetDefault("stored_requests.in_memory_cache.ttl_seconds", 0)
v.SetDefault("stored_requests.in_memory_cache.request_cache_size_bytes", 0)
v.SetDefault("stored_requests.in_memory_cache.imp_cache_size_bytes", 0)
v.SetDefault("stored_requests.in_memory_cache.resp_cache_size_bytes", 0)
v.SetDefault("stored_requests.cache_events_api", false)
v.SetDefault("stored_requests.http_events.endpoint", "")
v.SetDefault("stored_requests.http_events.amp_endpoint", "")
v.SetDefault("stored_requests.http_events.refresh_rate_seconds", 0)
v.SetDefault("stored_requests.http_events.timeout_ms", 0)
// stored_video is short for stored_video_requests.
// PBS is not in the business of storing video content beyond the normal prebid cache system.
v.SetDefault("stored_video_req.database.connection.driver", "")
v.SetDefault("stored_video_req.database.connection.dbname", "")
v.SetDefault("stored_video_req.database.connection.host", "")
v.SetDefault("stored_video_req.database.connection.port", 0)
v.SetDefault("stored_video_req.database.connection.user", "")
v.SetDefault("stored_video_req.database.connection.password", "")
v.SetDefault("stored_video_req.database.connection.query_string", "")
v.SetDefault("stored_video_req.database.connection.tls.root_cert", "")
v.SetDefault("stored_video_req.database.connection.tls.client_cert", "")
v.SetDefault("stored_video_req.database.connection.tls.client_key", "")
v.SetDefault("stored_video_req.database.fetcher.query", "")
v.SetDefault("stored_video_req.database.fetcher.amp_query", "")
v.SetDefault("stored_video_req.database.initialize_caches.timeout_ms", 0)
v.SetDefault("stored_video_req.database.initialize_caches.query", "")
v.SetDefault("stored_video_req.database.initialize_caches.amp_query", "")
v.SetDefault("stored_video_req.database.poll_for_updates.refresh_rate_seconds", 0)
v.SetDefault("stored_video_req.database.poll_for_updates.timeout_ms", 0)
v.SetDefault("stored_video_req.database.poll_for_updates.query", "")
v.SetDefault("stored_video_req.database.poll_for_updates.amp_query", "")