check db_replica_url being the same as db_url
This commit is contained in:
parent
ef64ee0a12
commit
fc48f2469c
@ -359,9 +359,15 @@ impl Web3ProxyApp {
|
|||||||
.db_max_connections
|
.db_max_connections
|
||||||
.unwrap_or(db_min_connections * 2);
|
.unwrap_or(db_min_connections * 2);
|
||||||
|
|
||||||
db_conn = Some(get_migrated_db(db_url, db_min_connections, db_max_connections).await?);
|
db_conn = Some(
|
||||||
|
get_migrated_db(db_url.clone(), db_min_connections, db_max_connections).await?,
|
||||||
|
);
|
||||||
|
|
||||||
db_replica = if let Some(db_replica_url) = top_config.app.db_replica_url.clone() {
|
db_replica = if let Some(db_replica_url) = top_config.app.db_replica_url.clone() {
|
||||||
|
if db_replica_url == db_url {
|
||||||
|
// url is the same. do not make a new connection or we might go past our max connections
|
||||||
|
db_conn.clone().map(DatabaseReplica)
|
||||||
|
} else {
|
||||||
let db_replica_min_connections = top_config
|
let db_replica_min_connections = top_config
|
||||||
.app
|
.app
|
||||||
.db_replica_min_connections
|
.db_replica_min_connections
|
||||||
@ -380,6 +386,7 @@ impl Web3ProxyApp {
|
|||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Some(DatabaseReplica(db_replica))
|
Some(DatabaseReplica(db_replica))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// just clone so that we don't need a bunch of checks all over our code
|
// just clone so that we don't need a bunch of checks all over our code
|
||||||
db_conn.clone().map(DatabaseReplica)
|
db_conn.clone().map(DatabaseReplica)
|
||||||
|
Loading…
Reference in New Issue
Block a user