forked from couchbase/gocbcore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathagent_ops.go
283 lines (218 loc) · 11.6 KB
/
agent_ops.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
package gocbcore
import "github.com/couchbase/gocbcore/v10/memd"
// GetCallback is invoked upon completion of a Get operation.
type GetCallback func(*GetResult, error)
// Get retrieves a document.
func (agent *Agent) Get(opts GetOptions, cb GetCallback) (PendingOp, error) {
return agent.crud.Get(opts, cb)
}
// GetAndTouchCallback is invoked upon completion of a GetAndTouch operation.
type GetAndTouchCallback func(*GetAndTouchResult, error)
// GetAndTouch retrieves a document and updates its expiry.
func (agent *Agent) GetAndTouch(opts GetAndTouchOptions, cb GetAndTouchCallback) (PendingOp, error) {
return agent.crud.GetAndTouch(opts, cb)
}
// GetAndLockCallback is invoked upon completion of a GetAndLock operation.
type GetAndLockCallback func(*GetAndLockResult, error)
// GetAndLock retrieves a document and locks it.
func (agent *Agent) GetAndLock(opts GetAndLockOptions, cb GetAndLockCallback) (PendingOp, error) {
return agent.crud.GetAndLock(opts, cb)
}
// GetReplicaCallback is invoked upon completion of a GetReplica operation.
type GetReplicaCallback func(*GetReplicaResult, error)
// GetOneReplica retrieves a document from a replica server.
func (agent *Agent) GetOneReplica(opts GetOneReplicaOptions, cb GetReplicaCallback) (PendingOp, error) {
return agent.crud.GetOneReplica(opts, cb)
}
// TouchCallback is invoked upon completion of a Touch operation.
type TouchCallback func(*TouchResult, error)
// Touch updates the expiry for a document.
func (agent *Agent) Touch(opts TouchOptions, cb TouchCallback) (PendingOp, error) {
return agent.crud.Touch(opts, cb)
}
// UnlockCallback is invoked upon completion of a Unlock operation.
type UnlockCallback func(*UnlockResult, error)
// Unlock unlocks a locked document.
func (agent *Agent) Unlock(opts UnlockOptions, cb UnlockCallback) (PendingOp, error) {
return agent.crud.Unlock(opts, cb)
}
// DeleteCallback is invoked upon completion of a Delete operation.
type DeleteCallback func(*DeleteResult, error)
// Delete removes a document.
func (agent *Agent) Delete(opts DeleteOptions, cb DeleteCallback) (PendingOp, error) {
return agent.crud.Delete(opts, cb)
}
// StoreCallback is invoked upon completion of a Add, Set or Replace operation.
type StoreCallback func(*StoreResult, error)
// Add stores a document as long as it does not already exist.
func (agent *Agent) Add(opts AddOptions, cb StoreCallback) (PendingOp, error) {
return agent.crud.Add(opts, cb)
}
// Set stores a document.
func (agent *Agent) Set(opts SetOptions, cb StoreCallback) (PendingOp, error) {
return agent.crud.Set(opts, cb)
}
// Replace replaces the value of a Couchbase document with another value.
func (agent *Agent) Replace(opts ReplaceOptions, cb StoreCallback) (PendingOp, error) {
return agent.crud.Replace(opts, cb)
}
// AdjoinCallback is invoked upon completion of a Append or Prepend operation.
type AdjoinCallback func(*AdjoinResult, error)
// Append appends some bytes to a document.
func (agent *Agent) Append(opts AdjoinOptions, cb AdjoinCallback) (PendingOp, error) {
return agent.crud.Append(opts, cb)
}
// Prepend prepends some bytes to a document.
func (agent *Agent) Prepend(opts AdjoinOptions, cb AdjoinCallback) (PendingOp, error) {
return agent.crud.Prepend(opts, cb)
}
// CounterCallback is invoked upon completion of a Increment or Decrement operation.
type CounterCallback func(*CounterResult, error)
// Increment increments the unsigned integer value in a document.
func (agent *Agent) Increment(opts CounterOptions, cb CounterCallback) (PendingOp, error) {
return agent.crud.Increment(opts, cb)
}
// Decrement decrements the unsigned integer value in a document.
func (agent *Agent) Decrement(opts CounterOptions, cb CounterCallback) (PendingOp, error) {
return agent.crud.Decrement(opts, cb)
}
// GetRandomCallback is invoked upon completion of a GetRandom operation.
type GetRandomCallback func(*GetRandomResult, error)
// GetRandom retrieves the key and value of a random document stored within Couchbase Server.
func (agent *Agent) GetRandom(opts GetRandomOptions, cb GetRandomCallback) (PendingOp, error) {
return agent.crud.GetRandom(opts, cb)
}
// GetMetaCallback is invoked upon completion of a GetMeta operation.
type GetMetaCallback func(*GetMetaResult, error)
// GetMeta retrieves a document along with some internal Couchbase meta-data.
func (agent *Agent) GetMeta(opts GetMetaOptions, cb GetMetaCallback) (PendingOp, error) {
return agent.crud.GetMeta(opts, cb)
}
// SetMetaCallback is invoked upon completion of a SetMeta operation.
type SetMetaCallback func(*SetMetaResult, error)
// SetMeta stores a document along with setting some internal Couchbase meta-data.
func (agent *Agent) SetMeta(opts SetMetaOptions, cb SetMetaCallback) (PendingOp, error) {
return agent.crud.SetMeta(opts, cb)
}
// DeleteMetaCallback is invoked upon completion of a DeleteMeta operation.
type DeleteMetaCallback func(*DeleteMetaResult, error)
// DeleteMeta deletes a document along with setting some internal Couchbase meta-data.
func (agent *Agent) DeleteMeta(opts DeleteMetaOptions, cb DeleteMetaCallback) (PendingOp, error) {
return agent.crud.DeleteMeta(opts, cb)
}
// StatsCallback is invoked upon completion of a Stats operation.
type StatsCallback func(*StatsResult, error)
// Stats retrieves statistics information from the server. Note that as this
// function is an aggregator across numerous servers, there are no guarantees
// about the consistency of the results. Occasionally, some nodes may not be
// represented in the results, or there may be conflicting information between
// multiple nodes (a vbucket active on two separate nodes at once).
func (agent *Agent) Stats(opts StatsOptions, cb StatsCallback) (PendingOp, error) {
return agent.stats.Stats(opts, cb)
}
// ObserveCallback is invoked upon completion of a Observe operation.
type ObserveCallback func(*ObserveResult, error)
// Observe retrieves the current CAS and persistence state for a document.
func (agent *Agent) Observe(opts ObserveOptions, cb ObserveCallback) (PendingOp, error) {
return agent.observe.Observe(opts, cb)
}
// ObserveVbCallback is invoked upon completion of a ObserveVb operation.
type ObserveVbCallback func(*ObserveVbResult, error)
// ObserveVb retrieves the persistence state sequence numbers for a particular VBucket
// and includes additional details not included by the basic version.
func (agent *Agent) ObserveVb(opts ObserveVbOptions, cb ObserveVbCallback) (PendingOp, error) {
return agent.observe.ObserveVb(opts, cb)
}
// SubDocOp defines a per-operation structure to be passed to MutateIn
// or LookupIn for performing many sub-document operations.
type SubDocOp struct {
Op memd.SubDocOpType
Flags memd.SubdocFlag
Path string
Value []byte
}
// LookupInCallback is invoked upon completion of a LookupIn operation.
type LookupInCallback func(*LookupInResult, error)
// LookupIn performs a multiple-lookup sub-document operation on a document.
func (agent *Agent) LookupIn(opts LookupInOptions, cb LookupInCallback) (PendingOp, error) {
return agent.crud.LookupIn(opts, cb)
}
// MutateInCallback is invoked upon completion of a MutateIn operation.
type MutateInCallback func(*MutateInResult, error)
// MutateIn performs a multiple-mutation sub-document operation on a document.
func (agent *Agent) MutateIn(opts MutateInOptions, cb MutateInCallback) (PendingOp, error) {
return agent.crud.MutateIn(opts, cb)
}
// N1QLQueryCallback is invoked upon completion of a N1QLQuery operation.
type N1QLQueryCallback func(*N1QLRowReader, error)
// N1QLQuery executes a N1QL query
func (agent *Agent) N1QLQuery(opts N1QLQueryOptions, cb N1QLQueryCallback) (PendingOp, error) {
return agent.n1ql.N1QLQuery(opts, cb)
}
// PreparedN1QLQuery executes a prepared N1QL query
func (agent *Agent) PreparedN1QLQuery(opts N1QLQueryOptions, cb N1QLQueryCallback) (PendingOp, error) {
return agent.n1ql.PreparedN1QLQuery(opts, cb)
}
// AnalyticsQueryCallback is invoked upon completion of a AnalyticsQuery operation.
type AnalyticsQueryCallback func(*AnalyticsRowReader, error)
// AnalyticsQuery executes an analytics query
func (agent *Agent) AnalyticsQuery(opts AnalyticsQueryOptions, cb AnalyticsQueryCallback) (PendingOp, error) {
return agent.analytics.AnalyticsQuery(opts, cb)
}
// SearchQueryCallback is invoked upon completion of a SearchQuery operation.
type SearchQueryCallback func(*SearchRowReader, error)
// SearchQuery executes a Search query
func (agent *Agent) SearchQuery(opts SearchQueryOptions, cb SearchQueryCallback) (PendingOp, error) {
return agent.search.SearchQuery(opts, cb)
}
// ViewQueryCallback is invoked upon completion of a ViewQuery operation.
type ViewQueryCallback func(*ViewQueryRowReader, error)
// ViewQuery executes a view query
func (agent *Agent) ViewQuery(opts ViewQueryOptions, cb ViewQueryCallback) (PendingOp, error) {
return agent.views.ViewQuery(opts, cb)
}
// DoHTTPRequestCallback is invoked upon completion of a DoHTTPRequest operation.
type DoHTTPRequestCallback func(*HTTPResponse, error)
// DoHTTPRequest will perform an HTTP request against one of the HTTP
// services which are available within the SDK.
func (agent *Agent) DoHTTPRequest(req *HTTPRequest, cb DoHTTPRequestCallback) (PendingOp, error) {
return agent.http.DoHTTPRequest(req, cb)
}
// GetCollectionManifestCallback is invoked upon completion of a GetCollectionManifest operation.
type GetCollectionManifestCallback func(*GetCollectionManifestResult, error)
// GetCollectionManifest fetches the current server manifest. This function will not update the client's collection
// id cache.
func (agent *Agent) GetCollectionManifest(opts GetCollectionManifestOptions, cb GetCollectionManifestCallback) (PendingOp, error) {
return agent.collections.GetCollectionManifest(opts, cb)
}
// GetAllCollectionManifestsCallback is invoked upon completion of a GetAllCollectionManifests operation.
type GetAllCollectionManifestsCallback func(*GetAllCollectionManifestsResult, error)
// GetAllCollectionManifests fetches the collection manifest from each server in the cluster, note that it's possible
// for one or mode nodes to be slightly behind when creating scopes/collections. This function will not update the
// client's collection id cache.
func (agent *Agent) GetAllCollectionManifests(opts GetAllCollectionManifestsOptions,
cb GetAllCollectionManifestsCallback) (PendingOp, error) {
return agent.collections.GetAllCollectionManifests(opts, cb)
}
// GetCollectionIDCallback is invoked upon completion of a GetCollectionID operation.
type GetCollectionIDCallback func(*GetCollectionIDResult, error)
// GetCollectionID fetches the collection id and manifest id that the collection belongs to, given a scope name
// and collection name. This function will also prime the client's collection id cache.
func (agent *Agent) GetCollectionID(scopeName string, collectionName string, opts GetCollectionIDOptions, cb GetCollectionIDCallback) (PendingOp, error) {
return agent.collections.GetCollectionID(scopeName, collectionName, opts, cb)
}
// PingCallback is invoked upon completion of a PingKv operation.
type PingCallback func(*PingResult, error)
// Ping pings all of the servers we are connected to and returns
// a report regarding the pings that were performed.
func (agent *Agent) Ping(opts PingOptions, cb PingCallback) (PendingOp, error) {
return agent.diagnostics.Ping(opts, cb)
}
// Diagnostics returns diagnostics information about the client.
// Mainly containing a list of open connections and their current
// states.
func (agent *Agent) Diagnostics(opts DiagnosticsOptions) (*DiagnosticInfo, error) {
return agent.diagnostics.Diagnostics(opts)
}
// WaitUntilReadyCallback is invoked upon completion of a WaitUntilReady operation.
type WaitUntilReadyCallback func(*WaitUntilReadyResult, error)