Skip to content

Commit 9750c93

Browse files
remove unnecessary hacks from dsn option
1 parent 0a323c8 commit 9750c93

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

options.go

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"crypto/x509"
66
"encoding/pem"
7+
"fmt"
78
"io/ioutil"
89
"os"
910
"path/filepath"
@@ -62,27 +63,13 @@ func WithRequestsType(requestsType string) Option {
6263
// (connection string will be required string param of ydb.Open)
6364
func WithConnectionString(connectionString string) Option {
6465
return func(ctx context.Context, c *connection) error {
65-
var (
66-
urls = []string{
67-
connectionString,
68-
"grpcs://" + connectionString,
69-
}
70-
issues = make([]error, 0, len(urls))
71-
)
72-
for _, url := range urls {
73-
options, err := dsn.Parse(url)
74-
if err == nil {
75-
c.options = append(c.options, options...)
76-
return nil
77-
}
78-
issues = append(issues, err)
79-
}
80-
if len(issues) > 0 {
81-
return xerrors.WithStackTrace(xerrors.NewWithIssues(
82-
"parse connection string '"+connectionString+"' failed:",
83-
issues...,
84-
))
66+
options, err := dsn.Parse(connectionString)
67+
if err != nil {
68+
return xerrors.WithStackTrace(
69+
fmt.Errorf("parse connection string '%s' failed: %w", connectionString, err),
70+
)
8571
}
72+
c.options = append(c.options, options...)
8673
return nil
8774
}
8875
}

0 commit comments

Comments
 (0)