Skip to content

Commit

Permalink
fix(userservice): init db for reports
Browse files Browse the repository at this point in the history
  • Loading branch information
guybrush committed Sep 26, 2024
1 parent 80d2c12 commit 59c4a0b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
24 changes: 24 additions & 0 deletions backend/cmd/user_service/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,30 @@ func Run() {
}, "pgx", "postgres")
}()

wg.Add(1)
go func() {
defer wg.Done()
db.WriterDb, db.ReaderDb = db.MustInitDB(&types.DatabaseConfig{
Username: utils.Config.WriterDatabase.Username,
Password: utils.Config.WriterDatabase.Password,
Name: utils.Config.WriterDatabase.Name,
Host: utils.Config.WriterDatabase.Host,
Port: utils.Config.WriterDatabase.Port,
MaxOpenConns: utils.Config.WriterDatabase.MaxOpenConns,
MaxIdleConns: utils.Config.WriterDatabase.MaxIdleConns,
SSL: utils.Config.WriterDatabase.SSL,
}, &types.DatabaseConfig{
Username: utils.Config.ReaderDatabase.Username,
Password: utils.Config.ReaderDatabase.Password,
Name: utils.Config.ReaderDatabase.Name,
Host: utils.Config.ReaderDatabase.Host,
Port: utils.Config.ReaderDatabase.Port,
MaxOpenConns: utils.Config.ReaderDatabase.MaxOpenConns,
MaxIdleConns: utils.Config.ReaderDatabase.MaxIdleConns,
SSL: utils.Config.ReaderDatabase.SSL,
}, "pgx", "postgres")
}()

// if needed, init the database, cache or bigtable

wg.Wait()
Expand Down
1 change: 1 addition & 0 deletions backend/pkg/api/data_access/data_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ func createDataAccessService(cfg *types.Config) *DataAccessService {
Port: cfg.Frontend.ReaderDatabase.Port,
MaxOpenConns: cfg.Frontend.ReaderDatabase.MaxOpenConns,
MaxIdleConns: cfg.Frontend.ReaderDatabase.MaxIdleConns,
SSL: cfg.Frontend.ReaderDatabase.SSL,
}, "pgx", "postgres",
)
}()
Expand Down

0 comments on commit 59c4a0b

Please sign in to comment.