feature: integrate SSL mode for PG connections (#77)

Right now, the default connection for postgres is `disable`. Some
databases require `verify` or even `required`.
This PR introduces a new implementation that allows the user to override
the `disable` mode. The PR keeps a backwards compatible config entry, that
sets the default behavior to `disable` if it's missing.
This commit is contained in:
Roman
2021-05-18 13:00:40 +02:00
committed by GitHub
parent b9b7ed25ca
commit 7bbbc01f84
4 changed files with 33 additions and 1 deletions

View File

@@ -36,6 +36,11 @@ type Config struct {
// Optional. Default is "fiber_storage"
Table string
// The SSL mode for the connection
//
// Optional. Default is "disable"
SslMode string
// Reset clears any existing keys in existing Table
//
// Optional. Default is false
@@ -89,6 +94,7 @@ var ConfigDefault = Config{
Port: 5432,
Database: "fiber",
Table: "fiber_storage",
SslMode: "disable",
Reset: false,
GCInterval: 10 * time.Second,
maxOpenConns: 100,
@@ -119,6 +125,9 @@ func configDefault(config ...Config) Config {
if cfg.Table == "" {
cfg.Table = ConfigDefault.Table
}
if cfg.SslMode == "" {
cfg.SslMode = ConfigDefault.SslMode
}
if int(cfg.GCInterval.Seconds()) <= 0 {
cfg.GCInterval = ConfigDefault.GCInterval
}