Skip to content

Commit

Permalink
GOCBC-1611: Use gocbconnstr for parsing couchbase connstr
Browse files Browse the repository at this point in the history
Change-Id: I66e751c42cd7adead992f36b79cf8550aa2b887f
Reviewed-on: https://review.couchbase.org/c/gocb/+/211067
Reviewed-by: Dimitris Christodoulou <dimitris.christodoulou@couchbase.com>
Tested-by: Build Bot <build@couchbase.com>
  • Loading branch information
chvck committed Jun 7, 2024
1 parent f9016f8 commit cc77385
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions client_ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"github.com/couchbaselabs/gocbconnstr/v2"
"sync"
"sync/atomic"
"time"
Expand Down Expand Up @@ -48,11 +49,12 @@ func (c *psConnectionMgr) openBucket(bucketName string) error {
}

func (c *psConnectionMgr) buildConfig(cluster *Cluster) error {
port := cluster.connSpec().Addresses[0].Port
if port == -1 {
port = 18098
resolved, err := gocbconnstr.Resolve(cluster.connSpec())
if err != nil {
return err
}
c.host = fmt.Sprintf("%s:%d", cluster.connSpec().Addresses[0].Host, port)

c.host = fmt.Sprintf("%s:%d", resolved.Couchbase2Host.Host, resolved.Couchbase2Host.Port)

creds, err := cluster.authenticator().Credentials(AuthCredsRequest{})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require (
github.com/couchbase/gocbcoreps v0.1.3-0.20240408143129-4eb6ff9e2678
github.com/couchbase/goprotostellar v1.0.2
github.com/couchbaselabs/gocaves/client v0.0.0-20230404095311-05e3ba4f0259
github.com/couchbaselabs/gocbconnstr/v2 v2.0.0-20230515165046-68b522a21131
github.com/couchbaselabs/gocbconnstr/v2 v2.0.0-20240607131231-fb385523de28
github.com/golang/snappy v0.0.4
github.com/google/uuid v1.6.0
github.com/stretchr/testify v1.9.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ github.com/couchbase/goprotostellar v1.0.2 h1:yoPbAL9sCtcyZ5e/DcU5PRMOEFaJrF9awX
github.com/couchbase/goprotostellar v1.0.2/go.mod h1:5/yqVnZlW2/NSbAWu1hPJCFBEwjxgpe0PFFOlRixnp4=
github.com/couchbaselabs/gocaves/client v0.0.0-20230404095311-05e3ba4f0259 h1:2TXy68EGEzIMHOx9UvczR5ApVecwCfQZ0LjkmwMI6g4=
github.com/couchbaselabs/gocaves/client v0.0.0-20230404095311-05e3ba4f0259/go.mod h1:AVekAZwIY2stsJOMWLAS/0uA/+qdp7pjO8EHnl61QkY=
github.com/couchbaselabs/gocbconnstr/v2 v2.0.0-20230515165046-68b522a21131 h1:2EAfFswAfgYn3a05DVcegiw6DgMgn1Mv5eGz6IHt1Cw=
github.com/couchbaselabs/gocbconnstr/v2 v2.0.0-20230515165046-68b522a21131/go.mod h1:o7T431UOfFVHDNvMBUmUxpHnhivwv7BziUao/nMl81E=
github.com/couchbaselabs/gocbconnstr/v2 v2.0.0-20240607131231-fb385523de28 h1:lhGOw8rNG6RAadmmaJAF3PJ7MNt7rFuWG7BHCYMgnGE=
github.com/couchbaselabs/gocbconnstr/v2 v2.0.0-20240607131231-fb385523de28/go.mod h1:o7T431UOfFVHDNvMBUmUxpHnhivwv7BziUao/nMl81E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down

0 comments on commit cc77385

Please sign in to comment.