Reputation: 816
I have a TCP server that tries to connect to a Couchbase database using the go-couchbase client library but I get an error saying that the bucket that I'm trying to access, named "events", doesn't exist.
When I use the official Couchbase client library for Go everything works fine.
The difference that I noticed between these two clients is the concept of "pool". I have set this pool to be "default".
What could lead to this Go client not seeing my bucket?
cb, err := couchbase.Connect("http://address:port")
if err != nil {
log.Fatalf("Error connecting: %v", err)
}
cbPool, err := cb.GetPool("default")
if err != nil {
log.Fatalf("Error getting pool: %v", err)
}
cbBucket, err := cbPool.GetBucketWithAuth("events", "username", "password")
if err != nil {
log.Fatalf("Error getting bucket: %v", err)
}
Upvotes: 2
Views: 482
Reputation: 5343
I'm assuming you're getting some kind of an authentication error. The API is a little bit confusing. GetBucketWithAuth should be called like this:
GetBucketWithAuth("events", "events", "password")
The reason is that the client wants the bucket user name and the bucket password. The bucket username is the same as the bucket name.
With that said I would highly recommend that you use gocb and not go-couchbase. gocb is the official Couchbase go client and go-couchbase is only used internally inside Couchbase. In fact many of the components that use go-couchbase will start using gocb instead since this library is much easier to use and is better organized.
https://github.com/couchbase/gocb
Upvotes: 1