Add postgresql connection

Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
gearnode
2025-01-16 13:53:39 +01:00
parent b5ddb7d8cf
commit 8d86eacf87
4 changed files with 77 additions and 1 deletions

29
pkg/probod/pg_config.go Normal file
View File

@@ -0,0 +1,29 @@
package probod
import (
"go.gearno.de/kit/pg"
)
type (
pgConfig struct {
Addr string `json:"addr"`
Username string `json:"username"`
Password string `json:"password"`
Database string `json:"database"`
PoolSize int32 `json:"pool-size"`
}
)
func (cfg pgConfig) Options(options ...pg.Option) []pg.Option {
opts := []pg.Option{
pg.WithAddr(cfg.Addr),
pg.WithUser(cfg.Username),
pg.WithPassword(cfg.Password),
pg.WithDatabase(cfg.Database),
pg.WithPoolSize(cfg.PoolSize),
}
opts = append(opts, options...)
return opts
}