-
Notifications
You must be signed in to change notification settings - Fork 749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support MySql driver #2356
Support MySql driver #2356
Changes from 22 commits
4192762
db51dcf
6343c15
578c709
3a8c16f
71e91fb
2e5a7a8
71801ff
257b172
c2c68ff
81da8b3
c35b29d
ae396d2
1a2b592
bc16ac3
aa4c904
17b7068
9f46445
0a2c686
bf836b6
5afcc5e
5351540
98758bc
42e2f5c
3a63b20
a686ab8
a72deca
9b22905
2f63fd7
f0de6a6
8fa2287
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -848,20 +848,6 @@ func SetupViper(v *viper.Viper, filename string, bidderInfos BidderInfos) { | |
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.postgres.connection.dbname", "") | ||
v.SetDefault("stored_requests.postgres.connection.host", "") | ||
v.SetDefault("stored_requests.postgres.connection.port", 0) | ||
v.SetDefault("stored_requests.postgres.connection.user", "") | ||
v.SetDefault("stored_requests.postgres.connection.password", "") | ||
v.SetDefault("stored_requests.postgres.fetcher.query", "") | ||
v.SetDefault("stored_requests.postgres.fetcher.amp_query", "") | ||
v.SetDefault("stored_requests.postgres.initialize_caches.timeout_ms", 0) | ||
v.SetDefault("stored_requests.postgres.initialize_caches.query", "") | ||
v.SetDefault("stored_requests.postgres.initialize_caches.amp_query", "") | ||
v.SetDefault("stored_requests.postgres.poll_for_updates.refresh_rate_seconds", 0) | ||
v.SetDefault("stored_requests.postgres.poll_for_updates.timeout_ms", 0) | ||
v.SetDefault("stored_requests.postgres.poll_for_updates.query", "") | ||
v.SetDefault("stored_requests.postgres.poll_for_updates.amp_query", "") | ||
v.SetDefault("stored_requests.http.endpoint", "") | ||
v.SetDefault("stored_requests.http.amp_endpoint", "") | ||
v.SetDefault("stored_requests.in_memory_cache.type", "none") | ||
|
@@ -878,17 +864,6 @@ func SetupViper(v *viper.Viper, filename string, bidderInfos BidderInfos) { | |
// PBS is not in the business of storing video content beyond the normal prebid cache system. | ||
v.SetDefault("stored_video_req.filesystem.enabled", false) | ||
v.SetDefault("stored_video_req.filesystem.directorypath", "") | ||
v.SetDefault("stored_video_req.postgres.connection.dbname", "") | ||
v.SetDefault("stored_video_req.postgres.connection.host", "") | ||
v.SetDefault("stored_video_req.postgres.connection.port", 0) | ||
v.SetDefault("stored_video_req.postgres.connection.user", "") | ||
v.SetDefault("stored_video_req.postgres.connection.password", "") | ||
v.SetDefault("stored_video_req.postgres.fetcher.query", "") | ||
v.SetDefault("stored_video_req.postgres.initialize_caches.timeout_ms", 0) | ||
v.SetDefault("stored_video_req.postgres.initialize_caches.query", "") | ||
v.SetDefault("stored_video_req.postgres.poll_for_updates.refresh_rate_seconds", 0) | ||
v.SetDefault("stored_video_req.postgres.poll_for_updates.timeout_ms", 0) | ||
v.SetDefault("stored_video_req.postgres.poll_for_updates.query", "") | ||
v.SetDefault("stored_video_req.http.endpoint", "") | ||
v.SetDefault("stored_video_req.in_memory_cache.type", "none") | ||
v.SetDefault("stored_video_req.in_memory_cache.ttl_seconds", 0) | ||
|
@@ -902,17 +877,6 @@ func SetupViper(v *viper.Viper, filename string, bidderInfos BidderInfos) { | |
v.SetDefault("stored_video_req.http_events.timeout_ms", 0) | ||
v.SetDefault("stored_responses.filesystem.enabled", false) | ||
v.SetDefault("stored_responses.filesystem.directorypath", "") | ||
v.SetDefault("stored_responses.postgres.connection.dbname", "") | ||
v.SetDefault("stored_responses.postgres.connection.host", "") | ||
v.SetDefault("stored_responses.postgres.connection.port", 0) | ||
v.SetDefault("stored_responses.postgres.connection.user", "") | ||
v.SetDefault("stored_responses.postgres.connection.password", "") | ||
v.SetDefault("stored_responses.postgres.fetcher.query", "") | ||
v.SetDefault("stored_responses.postgres.initialize_caches.timeout_ms", 0) | ||
v.SetDefault("stored_responses.postgres.initialize_caches.query", "") | ||
v.SetDefault("stored_responses.postgres.poll_for_updates.refresh_rate_seconds", 0) | ||
v.SetDefault("stored_responses.postgres.poll_for_updates.timeout_ms", 0) | ||
v.SetDefault("stored_responses.postgres.poll_for_updates.query", "") | ||
v.SetDefault("stored_responses.http.endpoint", "") | ||
v.SetDefault("stored_responses.in_memory_cache.type", "none") | ||
v.SetDefault("stored_responses.in_memory_cache.ttl_seconds", 0) | ||
|
@@ -1037,6 +1001,7 @@ func SetupViper(v *viper.Viper, filename string, bidderInfos BidderInfos) { | |
migrateConfigPurposeOneTreatment(v) | ||
migrateConfigSpecialFeature1(v) | ||
migrateConfigTCF2PurposeFlags(v) | ||
migrateConfigDatabaseConnection(v) | ||
|
||
// These defaults must be set after the migrate functions because those functions look for the presence of these | ||
// config fields and there isn't a way to detect presence of a config field using the viper package if a default | ||
|
@@ -1186,6 +1151,160 @@ func migrateConfigTCF2PurposeEnabledFlags(v *viper.Viper) { | |
} | ||
} | ||
|
||
func migrateConfigDatabaseConnection(v *viper.Viper) { | ||
|
||
type QueryParamMigration struct { | ||
old string | ||
new string | ||
} | ||
|
||
type QueryMigration struct { | ||
name string | ||
params []QueryParamMigration | ||
} | ||
|
||
type Migration struct { | ||
old string | ||
new string | ||
fields []string | ||
queries []QueryMigration | ||
} | ||
|
||
migrations := []Migration{ | ||
{ | ||
old: "stored_requests.postgres", | ||
new: "stored_requests.database", | ||
fields: []string{ | ||
"connection.dbname", | ||
"connection.host", | ||
"connection.port", | ||
"connection.user", | ||
"connection.password", | ||
"fetcher.query", | ||
"fetcher.amp_query", | ||
"initialize_caches.timeout_ms", | ||
"initialize_caches.query", | ||
"initialize_caches.amp_query", | ||
"poll_for_updates.refresh_rate_seconds", | ||
"poll_for_updates.timeout_ms", | ||
"poll_for_updates.query", | ||
"poll_for_updates.amp_query", | ||
}, | ||
queries: []QueryMigration{ | ||
{ | ||
name: "fetcher.query", | ||
params: []QueryParamMigration{ | ||
{ | ||
old: "%REQUEST_ID_LIST%", | ||
new: "$REQUEST_ID_LIST", | ||
}, | ||
{ | ||
old: "%IMP_ID_LIST%", | ||
new: "$IMP_ID_LIST", | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "poll_for_updates.query", | ||
params: []QueryParamMigration{ | ||
{ | ||
old: "$1", | ||
new: "$LAST_UPDATED", | ||
}, | ||
}, | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we also need to migrate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated. |
||
}, | ||
}, | ||
{ | ||
old: "stored_video_req.postgres", | ||
new: "stored_video_req.database", | ||
fields: []string{ | ||
"connection.dbname", | ||
"connection.host", | ||
"connection.port", | ||
"connection.user", | ||
"connection.password", | ||
"fetcher.query", | ||
"initialize_caches.timeout_ms", | ||
"initialize_caches.query", | ||
"poll_for_updates.refresh_rate_seconds", | ||
"poll_for_updates.timeout_ms", | ||
"poll_for_updates.query", | ||
}, | ||
queries: []QueryMigration{}, | ||
}, | ||
{ | ||
old: "stored_responses.postgres", | ||
new: "stored_responses.database", | ||
fields: []string{ | ||
"connection.dbname", | ||
"connection.host", | ||
"connection.port", | ||
"connection.user", | ||
"connection.password", | ||
"fetcher.query", | ||
"initialize_caches.timeout_ms", | ||
"initialize_caches.query", | ||
"poll_for_updates.refresh_rate_seconds", | ||
"poll_for_updates.timeout_ms", | ||
"poll_for_updates.query", | ||
}, | ||
queries: []QueryMigration{ | ||
{ | ||
name: "fetcher.query", | ||
params: []QueryParamMigration{ | ||
{ | ||
old: "%ID_LIST%", | ||
new: "$ID_LIST", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
for _, migration := range migrations { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, I'm wondering if this function should instead only choose
@VeronikaSolovei9 thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point! Yes, "new" config should be used if it's specified. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated. |
||
driverField := migration.new + ".connection.driver" | ||
if !v.IsSet(migration.new) && v.IsSet(migration.old) { | ||
glog.Warning(fmt.Sprintf("%s is deprecated and should be changed to %s", migration.old, migration.new)) | ||
glog.Warning(fmt.Sprintf("%s is not set, using default (postgres)", driverField)) | ||
v.Set(driverField, "postgres") | ||
|
||
for _, field := range migration.fields { | ||
oldField := migration.old + "." + field | ||
newField := migration.new + "." + field | ||
if v.IsSet(oldField) { | ||
glog.Warning(fmt.Sprintf("%s is deprecated and should be changed to %s", oldField, newField)) | ||
v.Set(newField, v.Get(oldField)) | ||
} | ||
} | ||
|
||
for _, query := range migration.queries { | ||
oldQueryField := migration.old + "." + query.name | ||
newQueryField := migration.new + "." + query.name | ||
queryString := v.GetString(oldQueryField) | ||
for _, queryParam := range query.params { | ||
if strings.Contains(queryString, queryParam.old) { | ||
glog.Warning(fmt.Sprintf("Query param %s for %s is deprecated and should be changed to %s", queryParam.old, oldQueryField, queryParam.new)) | ||
queryString = strings.ReplaceAll(queryString, queryParam.old, queryParam.new) | ||
v.Set(newQueryField, queryString) | ||
} | ||
} | ||
} | ||
} else if v.IsSet(migration.new) && v.IsSet(migration.old) { | ||
glog.Warning(fmt.Sprintf("using %s and ignoring deprecated %s", migration.new, migration.old)) | ||
|
||
for _, field := range migration.fields { | ||
oldField := migration.old + "." + field | ||
newField := migration.new + "." + field | ||
if v.IsSet(oldField) { | ||
glog.Warning(fmt.Sprintf("using %s and ignoring deprecated %s", newField, oldField)) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
func setBidderDefaults(v *viper.Viper, bidder string) { | ||
adapterCfgPrefix := "adapters." + bidder | ||
v.BindEnv(adapterCfgPrefix+".disabled", "") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we also need to migrate
fetcher.amp_query
which should have the same parameters asfetcher.query
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.