Description
As of v1.6.5, it's not possible to use gocb's cluster.Manager to perform any operations without knowing the name of, and opening one already existing bucket.
Use case
I want to connect to an empty cluster, and create a new bucket using the SDK, and then open it to perform SDK operations on it.
This is caused by the change for GOCBC-794. Is this new behaviour intentional?
If so, what is the proposed workaround for the given use case?
Minimal repro
package main
|
|
import (
|
"github.com/couchbase/gocb"
|
)
|
|
func main() {
|
cluster, err := gocb.Connect("couchbase://192.168.1.20")
|
errPanic(err)
|
defer cluster.Close()
|
|
errPanic(cluster.Authenticate(gocb.PasswordAuthenticator{
|
Username: "Administrator",
|
Password: "password",
|
}))
|
|
clusterMgr := cluster.Manager("Administrator", "password")
|
|
errPanic(clusterMgr.InsertBucket(&gocb.BucketSettings{
|
Name: "testbucket",
|
Quota: 100,
|
Type: gocb.Couchbase,
|
FlushEnabled: true,
|
IndexReplicas: false,
|
Replicas: 0,
|
}))
|
}
|
|
func errPanic(err error) {
|
if err != nil {
|
panic(err)
|
}
|
}
|
✔ ~/dev/go/src/github.com/bbrks/gocb-bucketloop-test
|
13:52 $ go run main.go
|
|
✔ ~/dev/go/src/github.com/bbrks/gocb-bucketloop-test
|
13:52 $ # switch from gocb v1.6.4 to gocb v1.6.5
|
|
✔ ~/dev/go/src/github.com/bbrks/gocb-bucketloop-test
|
13:52 $ go run main.go
|
panic: You must open a bucket before you can perform cluster level operations.
|
|
goroutine 1 [running]:
|
main.errPanic(...)
|
/Users/benbrooks/dev/go/src/github.com/bbrks/gocb-bucketloop-test/main.go:31
|
main.main()
|
/Users/benbrooks/dev/go/src/github.com/bbrks/gocb-bucketloop-test/main.go:19 +0x32e
|
exit status 2
|
Attachments
Issue Links
- relates to
-
GOCBC-794 ClusterManager using non default couchbase port uses incorrect http addresses
- Resolved
For Gerrit Dashboard: GOCBC-821 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
123158,2 | GOCBC-821: Fallback to using supplied http addresses in cluster manager | v1 | gocb | Status: MERGED | +2 | +1 |