| 238 | } |
| 239 | |
| 240 | func (cc *CouchbaseCluster) getClusterConnection() (*gocb.Cluster, error) { |
| 241 | |
| 242 | if cc.bucketConnectionMode == PerUseClusterConnections { |
| 243 | return cc.connect(nil) |
| 244 | } |
| 245 | |
| 246 | cc.cachedConnectionLock.Lock() |
| 247 | defer cc.cachedConnectionLock.Unlock() |
| 248 | if cc.cachedClusterConnection != nil { |
| 249 | return cc.cachedClusterConnection, nil |
| 250 | } |
| 251 | |
| 252 | clusterConnection, err := cc.connect(nil) |
| 253 | if err != nil { |
| 254 | return nil, err |
| 255 | } |
| 256 | cc.cachedClusterConnection = clusterConnection |
| 257 | return cc.cachedClusterConnection, nil |
| 258 | |
| 259 | } |
| 260 | |
| 261 | func (cc *CouchbaseCluster) GetConfigBuckets() ([]string, error) { |
| 262 | if cc == nil { |