-
Notifications
You must be signed in to change notification settings - Fork 104
/
bucket_internal.go
47 lines (39 loc) · 1.55 KB
/
bucket_internal.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package gocb
import "github.com/couchbase/gocbcore/v10"
type kvCapabilityVerifier interface {
BucketCapabilityStatus(cap gocbcore.BucketCapability) gocbcore.CapabilityStatus
}
// InternalBucket is used for internal functionality.
// Internal: This should never be used and is not supported.
type InternalBucket struct {
bucket *Bucket
}
// Internal returns an InternalBucket.
// Internal: This should never be used and is not supported.
func (b *Bucket) Internal() *InternalBucket {
return &InternalBucket{bucket: b}
}
// IORouter returns the collection's internal core router.
func (ib *InternalBucket) IORouter() (*gocbcore.Agent, error) {
return ib.bucket.connectionManager.connection(ib.bucket.Name())
}
// HasCapabilityStatus verifies whether support for a server capability is in a given state.
func (ib *InternalBucket) CapabilityStatus(cap Capability) (CapabilityStatus, error) {
switch cap {
case CapabilityCreateAsDeleted:
return ib.bucketCapabilityStatus(gocbcore.BucketCapabilityCreateAsDeleted)
case CapabilityDurableWrites:
return ib.bucketCapabilityStatus(gocbcore.BucketCapabilityDurableWrites)
case CapabilityReplaceBodyWithXattr:
return ib.bucketCapabilityStatus(gocbcore.BucketCapabilityReplaceBodyWithXattr)
default:
return CapabilityStatusUnsupported, nil
}
}
func (ib *InternalBucket) bucketCapabilityStatus(capability gocbcore.BucketCapability) (CapabilityStatus, error) {
provider, err := ib.bucket.getKvCapabilitiesProvider()
if err != nil {
return 0, err
}
return CapabilityStatus(provider.BucketCapabilityStatus(capability)), nil
}