Skip to content

Commit

Permalink
common, cypress: Change our PG library to jackc/pgx/v5
Browse files Browse the repository at this point in the history
We've been using v3 so far, which was working well,
however its not supported by golang-migrate.

Initial impression of this new version is that it seems
needlessly complex. Although there's some documentation,
there doesn't seem to be much in the way of useful
examples.  There are no upgrade docs (eg "these new
types replace the old ones..."), nor release notes
(not even for major versions), etc. :/

So, this is definitely a "change", rather than an
"upgrade".
  • Loading branch information
justinclift committed May 3, 2023
1 parent 2454233 commit b542dc1
Show file tree
Hide file tree
Showing 6 changed files with 368 additions and 378 deletions.
17 changes: 6 additions & 11 deletions common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strconv"

"github.com/BurntSushi/toml"
"github.com/jackc/pgx"
"github.com/jackc/pgx/v5/pgxpool"
"github.com/mitchellh/go-homedir"
)

Expand All @@ -18,7 +18,7 @@ var (
Conf TomlConfig

// PostgreSQL configuration info
pgConfig = new(pgx.ConnConfig)
pgConfig *pgxpool.Config
)

// ReadConfig reads the server configuration file.
Expand Down Expand Up @@ -172,12 +172,9 @@ func ReadConfig() error {
}
}


// Set the PostgreSQL configuration values
pgConfig.Host = Conf.Pg.Server
pgConfig.Port = uint16(Conf.Pg.Port)
pgConfig.User = Conf.Pg.Username
pgConfig.Password = Conf.Pg.Password
pgConfig.Database = Conf.Pg.Database
pgConfig, err = pgxpool.ParseConfig(fmt.Sprintf("host=%s port=%d user= %s password = %s dbname=%s pool_max_conns=%d connect_timeout=10", Conf.Pg.Server, uint16(Conf.Pg.Port), Conf.Pg.Username, Conf.Pg.Password, Conf.Pg.Database, Conf.Pg.NumConnections))
clientTLSConfig := tls.Config{}
if Conf.Environment.Environment == "production" {
clientTLSConfig.ServerName = Conf.Pg.Server
Expand All @@ -186,13 +183,11 @@ func ReadConfig() error {
clientTLSConfig.InsecureSkipVerify = true
}
if Conf.Pg.SSL {
pgConfig.TLSConfig = &clientTLSConfig
pgConfig.ConnConfig.TLSConfig = &clientTLSConfig
} else {
pgConfig.TLSConfig = nil
pgConfig.ConnConfig.TLSConfig = nil
}

// TODO: Add environment variable overrides for memcached

// Environment variable override for non-production logged-in user
tempString = os.Getenv("DBHUB_USERNAME")
if tempString != "" {
Expand Down
Loading

0 comments on commit b542dc1

Please sign in to comment.