-
Notifications
You must be signed in to change notification settings - Fork 104
/
collection_subdoc.go
153 lines (125 loc) · 4.85 KB
/
collection_subdoc.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
package gocb
import (
"context"
"time"
)
// LookupInOptions are the set of options available to LookupIn.
type LookupInOptions struct {
Timeout time.Duration
RetryStrategy RetryStrategy
ParentSpan RequestSpan
// Using a deadlined Context alongside a Timeout will cause the shorter of the two to cause cancellation, this
// also applies to global level timeouts.
// UNCOMMITTED: This API may change in the future.
Context context.Context
// Internal: This should never be used and is not supported.
Internal struct {
DocFlags SubdocDocFlag
User string
}
noMetrics bool
}
// LookupIn performs a set of subdocument lookup operations on the document identified by id.
func (c *Collection) LookupIn(id string, ops []LookupInSpec, opts *LookupInOptions) (docOut *LookupInResult, errOut error) {
return autoOpControl(c.kvController(), func(agent kvProvider) (*LookupInResult, error) {
if opts == nil {
opts = &LookupInOptions{}
}
return agent.LookupIn(c, id, ops, opts)
})
}
// LookupInAnyReplicaOptions are the set of options available to LookupInAnyReplica.
type LookupInAnyReplicaOptions struct {
Timeout time.Duration
RetryStrategy RetryStrategy
ParentSpan RequestSpan
// UNCOMMITTED: This API may change in the future.
ReadPreference ReadPreference
// Using a deadlined Context alongside a Timeout will cause the shorter of the two to cause cancellation, this
// also applies to global level timeouts.
// UNCOMMITTED: This API may change in the future.
Context context.Context
// Internal: This should never be used and is not supported.
Internal struct {
DocFlags SubdocDocFlag
User string
}
}
// LookupInAnyReplica returns the value of a particular document from a replica server.
func (c *Collection) LookupInAnyReplica(id string, ops []LookupInSpec, opts *LookupInAnyReplicaOptions) (*LookupInReplicaResult, error) {
return autoOpControl(c.kvController(), func(agent kvProvider) (*LookupInReplicaResult, error) {
if opts == nil {
opts = &LookupInAnyReplicaOptions{}
}
return agent.LookupInAnyReplica(c, id, ops, opts)
})
}
// LookupInAllReplicaOptions are the set of options available to LookupInAllReplicas.
type LookupInAllReplicaOptions struct {
Timeout time.Duration
RetryStrategy RetryStrategy
ParentSpan RequestSpan
// UNCOMMITTED: This API may change in the future.
ReadPreference ReadPreference
// Using a deadlined Context alongside a Timeout will cause the shorter of the two to cause cancellation, this
// also applies to global level timeouts.
// UNCOMMITTED: This API may change in the future.
Context context.Context
// Internal: This should never be used and is not supported.
Internal struct {
DocFlags SubdocDocFlag
User string
}
}
// LookupInAllReplicas returns the value of a particular document from all replica servers. This will return an iterable
// which streams results one at a time.
func (c *Collection) LookupInAllReplicas(id string, ops []LookupInSpec, opts *LookupInAllReplicaOptions) (*LookupInAllReplicasResult, error) {
return autoOpControl(c.kvController(), func(agent kvProvider) (*LookupInAllReplicasResult, error) {
if opts == nil {
opts = &LookupInAllReplicaOptions{}
}
return agent.LookupInAllReplicas(c, id, ops, opts)
})
}
// StoreSemantics is used to define the document level action to take during a MutateIn operation.
type StoreSemantics uint8
const (
// StoreSemanticsReplace signifies to Replace the document, and fail if it does not exist.
// This is the default action
StoreSemanticsReplace StoreSemantics = iota
// StoreSemanticsUpsert signifies to replace the document or create it if it doesn't exist.
StoreSemanticsUpsert
// StoreSemanticsInsert signifies to create the document, and fail if it exists.
StoreSemanticsInsert
)
// MutateInOptions are the set of options available to MutateIn.
type MutateInOptions struct {
Expiry time.Duration
Cas Cas
PersistTo uint
ReplicateTo uint
DurabilityLevel DurabilityLevel
StoreSemantic StoreSemantics
Timeout time.Duration
RetryStrategy RetryStrategy
ParentSpan RequestSpan
PreserveExpiry bool
// Using a deadlined Context alongside a Timeout will cause the shorter of the two to cause cancellation, this
// also applies to global level timeouts.
// UNCOMMITTED: This API may change in the future.
Context context.Context
// Internal: This should never be used and is not supported.
Internal struct {
DocFlags SubdocDocFlag
User string
}
}
// MutateIn performs a set of subdocument mutations on the document specified by id.
func (c *Collection) MutateIn(id string, ops []MutateInSpec, opts *MutateInOptions) (mutOut *MutateInResult, errOut error) {
return autoOpControl(c.kvController(), func(agent kvProvider) (*MutateInResult, error) {
if opts == nil {
opts = &MutateInOptions{}
}
return agent.MutateIn(c, id, ops, opts)
})
}