Fix healthcheck

This commit is contained in:
Victor Lacasse-Beaudoin 2023-06-03 20:16:41 -04:00
parent 36c04e656d
commit f7981715db
4 changed files with 53 additions and 14 deletions

View file

@ -6,6 +6,7 @@ import (
"git.agecem.com/agecem/bottin-agenda/models"
_ "github.com/jackc/pgx/stdlib"
"github.com/jmoiron/sqlx"
"github.com/spf13/viper"
)
// DataClient is a postgres client based on sqlx
@ -23,6 +24,18 @@ type PostgresConnection struct {
SSL bool
}
func NewDataClientFromViper() (*DataClient, error) {
client, err := NewDataClient(PostgresConnection{
User: viper.GetString("db.user"),
Password: viper.GetString("db.password"),
Host: viper.GetString("db.host"),
Port: viper.GetInt("db.port"),
Database: viper.GetString("db.database"),
})
return client, err
}
func NewDataClient(connection PostgresConnection) (*DataClient, error) {
client := &DataClient{PostgresConnection: connection}