@@ -16,31 +16,31 @@ var (
1616 DBReadReplica * gorm.DB
1717 OtherAdvisoryTypes []string
1818 AdvisoryTypes map [int ]string
19- globalPgConfig * PostgreSQLConfig
20- globalPgReadReplicaConfig * PostgreSQLConfig
19+ globalPgConfig PostgreSQLConfig
20+ globalPgReadReplicaConfig PostgreSQLConfig
2121)
2222
23- func initDB (db * gorm.DB , pgConfig * PostgreSQLConfig , globalPgConfig * PostgreSQLConfig ) * gorm.DB {
24- if db == nil || pgConfig != globalPgConfig {
23+ func initDB (db * gorm.DB , pgConfig PostgreSQLConfig , globalPgConfig * PostgreSQLConfig ) * gorm.DB {
24+ if db == nil || pgConfig != * globalPgConfig {
2525 // create new connection if not already exists
26- globalPgConfig = pgConfig
27- db = openPostgreSQL (pgConfig )
26+ * globalPgConfig = pgConfig
27+ db = openPostgreSQL (globalPgConfig )
2828 }
2929 check (db )
3030 return db
3131}
3232
3333func InitAdminDB () {
3434 pgConfig := createPostgreSQLPrimaryAdminConfig ()
35- DB = initDB (DB , pgConfig , globalPgConfig )
35+ DB = initDB (DB , pgConfig , & globalPgConfig )
3636}
3737
3838func InitUserDB () {
3939 pgConfig := createPostgreSQLPrimaryUserConfig ()
40- DB = initDB (DB , pgConfig , globalPgConfig )
40+ DB = initDB (DB , pgConfig , & globalPgConfig )
4141 if utils .CoreCfg .DBReadReplicaEnabled && ReadReplicaConfigured () {
4242 pgConfig := createPostgreSQLReplicaConfig ()
43- DBReadReplica = initDB (DBReadReplica , pgConfig , globalPgReadReplicaConfig )
43+ DBReadReplica = initDB (DBReadReplica , pgConfig , & globalPgReadReplicaConfig )
4444 }
4545}
4646
@@ -117,7 +117,7 @@ func check(db *gorm.DB) {
117117}
118118
119119// load database config from environment vars using inserted prefix
120- func createPostgreSQLPrimaryConfig () * PostgreSQLConfig {
120+ func createPostgreSQLPrimaryConfig () PostgreSQLConfig {
121121 config := PostgreSQLConfig {
122122 Host : utils .CoreCfg .DBHost ,
123123 Port : utils .CoreCfg .DBPort ,
@@ -130,10 +130,10 @@ func createPostgreSQLPrimaryConfig() *PostgreSQLConfig {
130130 MaxIdleConnections : utils .CoreCfg .DBMaxIdleConnections ,
131131 MaxConnectionLifetimeS : utils .CoreCfg .DBMaxConnectionLifetimeS ,
132132 }
133- return & config
133+ return config
134134}
135135
136- func createPostgreSQLReplicaConfig () * PostgreSQLConfig {
136+ func createPostgreSQLReplicaConfig () PostgreSQLConfig {
137137 config := createPostgreSQLPrimaryConfig ()
138138 config .User = utils .CoreCfg .DBUser
139139 config .Passwd = utils .CoreCfg .DBPassword
@@ -142,14 +142,14 @@ func createPostgreSQLReplicaConfig() *PostgreSQLConfig {
142142 return config
143143}
144144
145- func createPostgreSQLPrimaryUserConfig () * PostgreSQLConfig {
145+ func createPostgreSQLPrimaryUserConfig () PostgreSQLConfig {
146146 config := createPostgreSQLPrimaryConfig ()
147147 config .User = utils .CoreCfg .DBUser
148148 config .Passwd = utils .CoreCfg .DBPassword
149149 return config
150150}
151151
152- func createPostgreSQLPrimaryAdminConfig () * PostgreSQLConfig {
152+ func createPostgreSQLPrimaryAdminConfig () PostgreSQLConfig {
153153 config := createPostgreSQLPrimaryConfig ()
154154 config .User = utils .CoreCfg .DBAdminUser
155155 config .Passwd = utils .CoreCfg .DBAdminPassword
0 commit comments