Esempio n. 1
0
func GetBucket(spec BucketSpec, callback sgbucket.BucketNotifyFn) (bucket Bucket, err error) {
	if isWalrus, _ := regexp.MatchString(`^(walrus:|file:|/|\.)`, spec.Server); isWalrus {
		Logf("Opening Walrus database %s on <%s>", spec.BucketName, spec.Server)
		sgbucket.SetLogging(LogEnabled("Walrus"))
		bucket, err = walrus.GetBucket(spec.Server, spec.PoolName, spec.BucketName)
		// If feed type is specified and isn't TAP, wrap with pseudo-vbucket handling for walrus
		if spec.FeedType != "" && spec.FeedType != TapFeedType {
			bucket = &LeakyBucket{bucket: bucket, config: LeakyBucketConfig{TapFeedVbuckets: true}}
		}
	} else {

		suffix := ""
		if spec.Auth != nil {
			username, _, _ := spec.Auth.GetCredentials()
			suffix = fmt.Sprintf(" as user %q", username)
		}
		Logf("Opening Couchbase database %s on <%s>%s", spec.BucketName, spec.Server, suffix)

		if spec.CouchbaseDriver == GoCB {
			bucket, err = GetCouchbaseBucketGoCB(spec)
		} else {
			bucket, err = GetCouchbaseBucket(spec, callback)
		}

	}

	if LogKeys["Bucket"] {
		bucket = &LoggingBucket{bucket: bucket}
	}
	return
}
Esempio n. 2
0
func GetBucket(url, poolName, bucketName string) (bucket Bucket, err error) {
	if isWalrus, _ := regexp.MatchString(`^(walrus:|file:|/|\.)`, url); isWalrus {
		Log("Opening Walrus database %s on <%s>", bucketName, url)
		walrus.Logging = LogKeys["Walrus"]
		return walrus.GetBucket(url, poolName, bucketName)
	}
	Log("Opening Couchbase database %s on <%s>", bucketName, url)
	return GetCouchbaseBucket(url, poolName, bucketName)
}
Esempio n. 3
0
func GetBucket(spec BucketSpec) (bucket Bucket, err error) {
	if isWalrus, _ := regexp.MatchString(`^(walrus:|file:|/|\.)`, spec.Server); isWalrus {
		Log("Opening Walrus database %s on <%s>", spec.BucketName, spec.Server)
		walrus.Logging = LogKeys["Walrus"]
		return walrus.GetBucket(spec.Server, spec.PoolName, spec.BucketName)
	}
	suffix := ""
	if spec.Auth != nil {
		username, _ := spec.Auth.GetCredentials()
		suffix = fmt.Sprintf(" as user %q", username)
	}
	Log("Opening Couchbase database %s on <%s>%s", spec.BucketName, spec.Server, suffix)
	return GetCouchbaseBucket(spec)
}
Esempio n. 4
0
func GetBucket(spec BucketSpec) (bucket Bucket, err error) {
	if isWalrus, _ := regexp.MatchString(`^(walrus:|file:|/|\.)`, spec.Server); isWalrus {
		Logf("Opening Walrus database %s on <%s>", spec.BucketName, spec.Server)
		sgbucket.Logging = LogKeys["Walrus"]
		bucket, err = walrus.GetBucket(spec.Server, spec.PoolName, spec.BucketName)
	} else {
		suffix := ""
		if spec.Auth != nil {
			username, _, _ := spec.Auth.GetCredentials()
			suffix = fmt.Sprintf(" as user %q", username)
		}
		Logf("Opening Couchbase database %s on <%s>%s", spec.BucketName, spec.Server, suffix)
		bucket, err = GetCouchbaseBucket(spec)
	}

	if LogKeys["Bucket"] {
		bucket = &LoggingBucket{bucket: bucket}
	}
	return
}