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

Function GetServerUUID

base/bucket.go:380–398  ·  view source on GitHub ↗

GetServerUUID returns Couchbase Server Cluster UUID on a timeout. If running against rosmar, do return an empty string.

(ctx context.Context, bucket Bucket)

Source from the content-addressed store, hash-verified

378
379// GetServerUUID returns Couchbase Server Cluster UUID on a timeout. If running against rosmar, do return an empty string.
380func GetServerUUID(ctx context.Context, bucket Bucket) (string, error) {
381 gocbV2Bucket, err := AsGocbV2Bucket(bucket)
382 if err != nil {
383 return "", nil
384 }
385 // start a retry loop to get server ID
386 worker := func() (bool, error, string) {
387 respBytes, _, err := gocbV2Bucket.MgmtRequest(ctx, http.MethodGet, "/pools", "application/json", nil)
388 if err != nil {
389 return true, err, ""
390 }
391
392 uuid, err := ParseClusterUUID(respBytes)
393 return false, err, uuid
394 }
395
396 err, uuid := RetryLoop(ctx, "Getting ServerUUID", worker, GetNewDatabaseSleeperFunc())
397 return uuid, err
398}
399
400func ParseClusterUUID(respBytes []byte) (string, error) {
401 var responseJson struct {

Callers 2

NewDatabaseContextFunction · 0.92
GetSourceIDFunction · 0.85

Calls 5

AsGocbV2BucketFunction · 0.85
ParseClusterUUIDFunction · 0.85
RetryLoopFunction · 0.85
MgmtRequestMethod · 0.65

Tested by

no test coverage detected