Skip to content

Commit

Permalink
remove DSN func and use ConnString
Browse files Browse the repository at this point in the history
  • Loading branch information
gusinacio committed Jul 10, 2023
1 parent 0bec73d commit 9285db8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cmd/substreams-sink-postgres/inject_csv.go
Expand Up @@ -64,7 +64,7 @@ func injectCSVE(cmd *cobra.Command, args []string) error {
return fmt.Errorf("unable to create input store: %w", err)
}

pool, err := pgxpool.Connect(ctx, fmt.Sprintf("%s pool_min_conns=%d pool_max_conns=%d", postgresDSN.DSN(), 2, 3))
pool, err := pgxpool.Connect(ctx, fmt.Sprintf("%s pool_min_conns=%d pool_max_conns=%d", postgresDSN.ConnString(), 2, 3))
if err != nil {
return fmt.Errorf("connecting to postgres: %w", err)
}
Expand Down
10 changes: 1 addition & 9 deletions db/dsn.go
Expand Up @@ -23,14 +23,6 @@ type DSN struct {
options []string
}

func (c *DSN) DSN() string {
out := fmt.Sprintf("host=%s port=%d user=%s dbname=%s %s", c.host, c.port, c.username, c.database, strings.Join(c.options, " "))
if c.password != "" {
out = out + " password=" + c.password
}
return out
}

func ParseDSN(dsn string) (*DSN, error) {
expanded, err := envsubst.Eval(dsn, os.Getenv)
if err != nil {
Expand Down Expand Up @@ -87,7 +79,7 @@ func ParseDSN(dsn string) (*DSN, error) {
return d, nil
}

func (c *DSN) connString() string {
func (c *DSN) ConnString() string {
out := fmt.Sprintf("host=%s port=%d user=%s dbname=%s %s", c.host, c.port, c.username, c.database, strings.Join(c.options, " "))
if c.password != "" {
out = out + " password=" + c.password
Expand Down

0 comments on commit 9285db8

Please sign in to comment.