Skip to content

Commit

Permalink
Adding default port for ydbs URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
kenshaw committed Dec 3, 2023
1 parent 18ad730 commit ffa572d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 6 additions & 0 deletions dburl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,12 @@ func TestParse(t *testing.T) {
`grpc://localhost:2136/`,
``,
},
{
`yds://`,
`ydb`,
`grpcs://localhost:2135/`,
``,
},
{
`ydbs://user:pass@localhost:8888/?opt1=a&opt2=b`,
`ydb`,
Expand Down
5 changes: 2 additions & 3 deletions dsn.go
Original file line number Diff line number Diff line change
Expand Up @@ -619,11 +619,10 @@ func GenVoltdb(u *URL) (string, string, error) {

// GenYDB generates a ydb dsn from the passed URL.
func GenYDB(u *URL) (string, string, error) {
scheme := "grpc"
scheme, host, port := "grpc", "localhost", "2136"
if strings.HasSuffix(strings.ToLower(u.OriginalScheme), "s") {
scheme += "s"
scheme, port = "grpcs", "2135"
}
host, port := "localhost", "2136"
if h := u.Hostname(); h != "" {
host = h
}
Expand Down

0 comments on commit ffa572d

Please sign in to comment.