MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / GetClusterVersion

Function GetClusterVersion

base/collection.go:96–105  ·  view source on GitHub ↗

GetClusterVersion returns major and minor versions of connected cluster

(cluster *gocb.Cluster)

Source from the content-addressed store, hash-verified

94
95// GetClusterVersion returns major and minor versions of connected cluster
96func GetClusterVersion(cluster *gocb.Cluster) (int, int, error) {
97 // Query node meta to find cluster compat version
98 nodesMetadata, err := cluster.Internal().GetNodesMetadata(&gocb.GetNodesMetadataOptions{})
99 if err != nil || len(nodesMetadata) == 0 {
100 return 0, 0, fmt.Errorf("unable to get server cluster compatibility for %d nodes: %w", len(nodesMetadata), err)
101 }
102 // Safe to get first node as there will always be at least one node in the list and cluster compat is uniform across all nodes.
103 clusterCompatMajor, clusterCompatMinor := decodeClusterVersion(nodesMetadata[0].ClusterCompatibility)
104 return clusterCompatMajor, clusterCompatMinor, nil
105}
106
107// GetGocbV2BucketFromCluster returns a gocb.Bucket from an existing gocb.Cluster
108func GetGocbV2BucketFromCluster(ctx context.Context, cluster *gocb.Cluster, spec BucketSpec, connstr string, waitUntilReady time.Duration, failFast bool) (*GocbV2Bucket, error) {

Callers 3

NewClusterOnlyN1QLStoreFunction · 0.85

Calls 2

decodeClusterVersionFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected