@@ -16,30 +16,30 @@ 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 ) {
24- if db == nil || pgConfig != globalPgConfig {
23+ func initDB (db * gorm.DB , pgConfig PostgreSQLConfig , globalPgConfig * PostgreSQLConfig ) {
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}
3131
3232func InitAdminDB () {
3333 pgConfig := createPostgreSQLPrimaryAdminConfig ()
34- initDB (DB , pgConfig , globalPgConfig )
34+ initDB (DB , pgConfig , & globalPgConfig )
3535}
3636
3737func InitUserDB () {
3838 pgConfig := createPostgreSQLPrimaryUserConfig ()
39- initDB (DB , pgConfig , globalPgConfig )
39+ initDB (DB , pgConfig , & globalPgConfig )
4040 if utils .CoreCfg .DBReadReplicaEnabled {
4141 pgConfig := createPostgreSQLReplicaConfig ()
42- initDB (DBReadReplica , pgConfig , globalPgReadReplicaConfig )
42+ initDB (DBReadReplica , pgConfig , & globalPgReadReplicaConfig )
4343 }
4444}
4545
@@ -116,7 +116,7 @@ func check(db *gorm.DB) {
116116}
117117
118118// load database config from environment vars using inserted prefix
119- func createPostgreSQLPrimaryConfig () * PostgreSQLConfig {
119+ func createPostgreSQLPrimaryConfig () PostgreSQLConfig {
120120 config := PostgreSQLConfig {
121121 Host : utils .CoreCfg .DBHost ,
122122 Port : utils .CoreCfg .DBPort ,
@@ -129,10 +129,10 @@ func createPostgreSQLPrimaryConfig() *PostgreSQLConfig {
129129 MaxIdleConnections : utils .CoreCfg .DBMaxIdleConnections ,
130130 MaxConnectionLifetimeS : utils .CoreCfg .DBMaxConnectionLifetimeS ,
131131 }
132- return & config
132+ return config
133133}
134134
135- func createPostgreSQLReplicaConfig () * PostgreSQLConfig {
135+ func createPostgreSQLReplicaConfig () PostgreSQLConfig {
136136 config := createPostgreSQLPrimaryConfig ()
137137 config .User = utils .CoreCfg .DBUser
138138 config .Passwd = utils .CoreCfg .DBPassword
@@ -141,14 +141,14 @@ func createPostgreSQLReplicaConfig() *PostgreSQLConfig {
141141 return config
142142}
143143
144- func createPostgreSQLPrimaryUserConfig () * PostgreSQLConfig {
144+ func createPostgreSQLPrimaryUserConfig () PostgreSQLConfig {
145145 config := createPostgreSQLPrimaryConfig ()
146146 config .User = utils .CoreCfg .DBUser
147147 config .Passwd = utils .CoreCfg .DBPassword
148148 return config
149149}
150150
151- func createPostgreSQLPrimaryAdminConfig () * PostgreSQLConfig {
151+ func createPostgreSQLPrimaryAdminConfig () PostgreSQLConfig {
152152 config := createPostgreSQLPrimaryConfig ()
153153 config .User = utils .CoreCfg .DBAdminUser
154154 config .Passwd = utils .CoreCfg .DBAdminPassword
0 commit comments