mirror of
https://github.com/gofiber/storage.git
synced 2025-09-28 05:12:19 +08:00
✨ 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:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user