couchbase 3.4.0-arm64-darwin-20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +202 -0
- data/README.md +154 -0
- data/ext/extconf.rb +0 -0
- data/lib/active_support/cache/couchbase_store.rb +339 -0
- data/lib/couchbase/analytics_options.rb +107 -0
- data/lib/couchbase/authenticator.rb +65 -0
- data/lib/couchbase/binary_collection.rb +128 -0
- data/lib/couchbase/binary_collection_options.rb +24 -0
- data/lib/couchbase/bucket.rb +144 -0
- data/lib/couchbase/cluster.rb +439 -0
- data/lib/couchbase/cluster_registry.rb +44 -0
- data/lib/couchbase/collection.rb +589 -0
- data/lib/couchbase/collection_options.rb +300 -0
- data/lib/couchbase/config_profiles.rb +55 -0
- data/lib/couchbase/configuration.rb +57 -0
- data/lib/couchbase/datastructures/couchbase_list.rb +160 -0
- data/lib/couchbase/datastructures/couchbase_map.rb +194 -0
- data/lib/couchbase/datastructures/couchbase_queue.rb +134 -0
- data/lib/couchbase/datastructures/couchbase_set.rb +128 -0
- data/lib/couchbase/datastructures.rb +24 -0
- data/lib/couchbase/diagnostics.rb +181 -0
- data/lib/couchbase/errors.rb +351 -0
- data/lib/couchbase/json_transcoder.rb +32 -0
- data/lib/couchbase/libcouchbase.bundle +0 -0
- data/lib/couchbase/logger.rb +85 -0
- data/lib/couchbase/management/analytics_index_manager.rb +1127 -0
- data/lib/couchbase/management/bucket_manager.rb +436 -0
- data/lib/couchbase/management/collection_manager.rb +321 -0
- data/lib/couchbase/management/query_index_manager.rb +520 -0
- data/lib/couchbase/management/search_index_manager.rb +408 -0
- data/lib/couchbase/management/user_manager.rb +468 -0
- data/lib/couchbase/management/view_index_manager.rb +237 -0
- data/lib/couchbase/management.rb +27 -0
- data/lib/couchbase/mutation_state.rb +63 -0
- data/lib/couchbase/options.rb +2580 -0
- data/lib/couchbase/query_options.rb +120 -0
- data/lib/couchbase/railtie.rb +45 -0
- data/lib/couchbase/scope.rb +232 -0
- data/lib/couchbase/search_options.rb +1570 -0
- data/lib/couchbase/subdoc.rb +290 -0
- data/lib/couchbase/utils/generic_logger_adapter.rb +38 -0
- data/lib/couchbase/utils/stdlib_logger_adapter.rb +65 -0
- data/lib/couchbase/utils/time.rb +56 -0
- data/lib/couchbase/utils.rb +21 -0
- data/lib/couchbase/version.rb +23 -0
- data/lib/couchbase/view_options.rb +65 -0
- data/lib/couchbase.rb +20 -0
- data/lib/rails/generators/couchbase/config/config_generator.rb +27 -0
- metadata +101 -0
@@ -0,0 +1,520 @@
|
|
1
|
+
# Copyright 2020-2021 Couchbase, Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require "couchbase/errors"
|
16
|
+
require "couchbase/options"
|
17
|
+
|
18
|
+
module Couchbase
|
19
|
+
module Management
|
20
|
+
module Options
|
21
|
+
module Query
|
22
|
+
# Options for {QueryIndexManager#get_all_indexes}
|
23
|
+
class GetAllIndexes < ::Couchbase::Options::Base
|
24
|
+
# Creates an instance of options for {QueryIndexManager#get_all_indexes}
|
25
|
+
#
|
26
|
+
# @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
|
27
|
+
# @param [Proc, nil] retry_strategy the custom retry strategy, if set
|
28
|
+
# @param [Hash, nil] client_context the client context data, if set
|
29
|
+
# @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
|
30
|
+
#
|
31
|
+
# @yieldparam [GetAllScopes] self
|
32
|
+
def initialize(timeout: nil,
|
33
|
+
retry_strategy: nil,
|
34
|
+
client_context: nil,
|
35
|
+
parent_span: nil)
|
36
|
+
super
|
37
|
+
yield self if block_given?
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# Options for {QueryIndexManager#create_index}
|
42
|
+
class CreateIndex < ::Couchbase::Options::Base
|
43
|
+
attr_accessor :ignore_if_exists # @return [Boolean]
|
44
|
+
attr_accessor :num_replicas # @return [Integer, nil]
|
45
|
+
attr_accessor :deferred # @return [Boolean]
|
46
|
+
attr_accessor :condition # @return [String, nil]
|
47
|
+
attr_accessor :scope_name # @return [String, nil]
|
48
|
+
attr_accessor :collection_name # @return [String, nil]
|
49
|
+
|
50
|
+
# Creates an instance of options for {QueryIndexManager#create_index}
|
51
|
+
#
|
52
|
+
# @param [Boolean] ignore_if_exists do not raise error if the index already exist
|
53
|
+
# @param [Integer] num_replicas the number of replicas that this index should have
|
54
|
+
# @param [Boolean] deferred whether the index should be created as a deferred index.
|
55
|
+
# @param [String, nil] condition to apply to the index
|
56
|
+
# @param [String, nil] scope_name the name of the scope
|
57
|
+
# @param [String, nil] collection_name the name of the collection
|
58
|
+
#
|
59
|
+
# @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
|
60
|
+
# @param [Proc, nil] retry_strategy the custom retry strategy, if set
|
61
|
+
# @param [Hash, nil] client_context the client context data, if set
|
62
|
+
# @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
|
63
|
+
#
|
64
|
+
# @yieldparam [CreateIndex] self
|
65
|
+
def initialize(ignore_if_exists: false,
|
66
|
+
num_replicas: nil,
|
67
|
+
deferred: false,
|
68
|
+
condition: nil,
|
69
|
+
scope_name: nil,
|
70
|
+
collection_name: nil,
|
71
|
+
timeout: nil,
|
72
|
+
retry_strategy: nil,
|
73
|
+
client_context: nil,
|
74
|
+
parent_span: nil)
|
75
|
+
super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
|
76
|
+
@ignore_if_exists = ignore_if_exists
|
77
|
+
@num_replicas = num_replicas
|
78
|
+
@deferred = deferred
|
79
|
+
@condition = condition
|
80
|
+
@scope_name = scope_name
|
81
|
+
@collection_name = collection_name
|
82
|
+
yield self if block_given?
|
83
|
+
end
|
84
|
+
|
85
|
+
# @api private
|
86
|
+
def to_backend
|
87
|
+
{
|
88
|
+
timeout: Utils::Time.extract_duration(@timeout),
|
89
|
+
ignore_if_exists: @ignore_if_exists,
|
90
|
+
condition: @condition,
|
91
|
+
deferred: @deferred,
|
92
|
+
num_replicas: @num_replicas,
|
93
|
+
scope_name: @scope_name,
|
94
|
+
collection_name: @collection_name,
|
95
|
+
}
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
# Options for {QueryIndexManager#create_primary_index}
|
100
|
+
class CreatePrimaryIndex < ::Couchbase::Options::Base
|
101
|
+
attr_accessor :ignore_if_exists # @return [Boolean]
|
102
|
+
attr_accessor :num_replicas # @return [Integer, nil]
|
103
|
+
attr_accessor :deferred # @return [Boolean]
|
104
|
+
attr_accessor :scope_name # @return [String, nil]
|
105
|
+
attr_accessor :collection_name # @return [String, nil]
|
106
|
+
|
107
|
+
# Creates an instance of options for {QueryIndexManager#create_primary_index}
|
108
|
+
#
|
109
|
+
# @param [Boolean] ignore_if_exists do not raise error if the index already exist
|
110
|
+
# @param [Integer] num_replicas the number of replicas that this index should have
|
111
|
+
# @param [Boolean] deferred whether the index should be created as a deferred index.
|
112
|
+
# @param [String, nil] scope_name the name of the scope
|
113
|
+
# @param [String, nil] collection_name the name of the collection
|
114
|
+
#
|
115
|
+
# @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
|
116
|
+
# @param [Proc, nil] retry_strategy the custom retry strategy, if set
|
117
|
+
# @param [Hash, nil] client_context the client context data, if set
|
118
|
+
# @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
|
119
|
+
#
|
120
|
+
# @yieldparam [CreatePrimaryIndex] self
|
121
|
+
def initialize(ignore_if_exists: false,
|
122
|
+
num_replicas: nil,
|
123
|
+
deferred: false,
|
124
|
+
scope_name: nil,
|
125
|
+
collection_name: nil,
|
126
|
+
timeout: nil,
|
127
|
+
retry_strategy: nil,
|
128
|
+
client_context: nil,
|
129
|
+
parent_span: nil)
|
130
|
+
super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
|
131
|
+
@ignore_if_exists = ignore_if_exists
|
132
|
+
@num_replicas = num_replicas
|
133
|
+
@deferred = deferred
|
134
|
+
@scope_name = scope_name
|
135
|
+
@collection_name = collection_name
|
136
|
+
yield self if block_given?
|
137
|
+
end
|
138
|
+
|
139
|
+
# @api private
|
140
|
+
def to_backend
|
141
|
+
{
|
142
|
+
timeout: Utils::Time.extract_duration(@timeout),
|
143
|
+
ignore_if_exists: @ignore_if_exists,
|
144
|
+
deferred: @deferred,
|
145
|
+
num_replicas: @num_replicas,
|
146
|
+
scope_name: @scope_name,
|
147
|
+
collection_name: @collection_name,
|
148
|
+
}
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
# Options for {QueryIndexManager#drop_index}
|
153
|
+
class DropIndex < ::Couchbase::Options::Base
|
154
|
+
attr_accessor :ignore_if_does_not_exist # @return [Boolean]
|
155
|
+
attr_accessor :scope_name # @return [String, nil]
|
156
|
+
attr_accessor :collection_name # @return [String, nil]
|
157
|
+
|
158
|
+
# Creates an instance of options for {QueryIndexManager#drop_index}
|
159
|
+
#
|
160
|
+
# @param [Boolean] ignore_if_does_not_exist do not raise error if the index does not exist
|
161
|
+
# @param [String, nil] scope_name the name of the scope
|
162
|
+
# @param [String, nil] collection_name the name of the collection
|
163
|
+
#
|
164
|
+
# @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
|
165
|
+
# @param [Proc, nil] retry_strategy the custom retry strategy, if set
|
166
|
+
# @param [Hash, nil] client_context the client context data, if set
|
167
|
+
# @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
|
168
|
+
#
|
169
|
+
# @yieldparam [DropIndex] self
|
170
|
+
def initialize(ignore_if_does_not_exist: false,
|
171
|
+
scope_name: nil,
|
172
|
+
collection_name: nil,
|
173
|
+
timeout: nil,
|
174
|
+
retry_strategy: nil,
|
175
|
+
client_context: nil,
|
176
|
+
parent_span: nil)
|
177
|
+
super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
|
178
|
+
@ignore_if_does_not_exist = ignore_if_does_not_exist
|
179
|
+
@scope_name = scope_name
|
180
|
+
@collection_name = collection_name
|
181
|
+
yield self if block_given?
|
182
|
+
end
|
183
|
+
|
184
|
+
# @api private
|
185
|
+
def to_backend
|
186
|
+
{
|
187
|
+
timeout: Utils::Time.extract_duration(@timeout),
|
188
|
+
ignore_if_does_not_exist: @ignore_if_does_not_exist,
|
189
|
+
scope_name: @scope_name,
|
190
|
+
collection_name: @collection_name,
|
191
|
+
}
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
# Options for {QueryIndexManager#drop_primary_index}
|
196
|
+
class DropPrimaryIndex < ::Couchbase::Options::Base
|
197
|
+
attr_accessor :ignore_if_does_not_exist # @return [Boolean]
|
198
|
+
attr_accessor :scope_name # @return [String, nil]
|
199
|
+
attr_accessor :collection_name # @return [String, nil]
|
200
|
+
|
201
|
+
# Creates an instance of options for {QueryIndexManager#drop_primary_index}
|
202
|
+
#
|
203
|
+
# @param [Boolean] ignore_if_does_not_exist do not raise error if the index does not exist
|
204
|
+
# @param [String, nil] scope_name the name of the scope
|
205
|
+
# @param [String, nil] collection_name the name of the collection
|
206
|
+
#
|
207
|
+
# @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
|
208
|
+
# @param [Proc, nil] retry_strategy the custom retry strategy, if set
|
209
|
+
# @param [Hash, nil] client_context the client context data, if set
|
210
|
+
# @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
|
211
|
+
#
|
212
|
+
# @yieldparam [DropPrimaryIndex] self
|
213
|
+
def initialize(ignore_if_does_not_exist: false,
|
214
|
+
scope_name: nil,
|
215
|
+
collection_name: nil,
|
216
|
+
timeout: nil,
|
217
|
+
retry_strategy: nil,
|
218
|
+
client_context: nil,
|
219
|
+
parent_span: nil)
|
220
|
+
super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
|
221
|
+
@ignore_if_does_not_exist = ignore_if_does_not_exist
|
222
|
+
@scope_name = scope_name
|
223
|
+
@collection_name = collection_name
|
224
|
+
yield self if block_given?
|
225
|
+
end
|
226
|
+
|
227
|
+
# @api private
|
228
|
+
def to_backend
|
229
|
+
{
|
230
|
+
timeout: Utils::Time.extract_duration(@timeout),
|
231
|
+
ignore_if_does_not_exist: @ignore_if_does_not_exist,
|
232
|
+
scope_name: @scope_name,
|
233
|
+
collection_name: @collection_name,
|
234
|
+
}
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
# Options for {QueryIndexManager#build_deferred_indexes}
|
239
|
+
class BuildDeferredIndexes < ::Couchbase::Options::Base
|
240
|
+
# Creates an instance of options for {QueryIndexManager#build_deferred_indexes}
|
241
|
+
#
|
242
|
+
# @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
|
243
|
+
# @param [Proc, nil] retry_strategy the custom retry strategy, if set
|
244
|
+
# @param [Hash, nil] client_context the client context data, if set
|
245
|
+
# @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
|
246
|
+
#
|
247
|
+
# @yieldparam [GetAllScopes] self
|
248
|
+
def initialize(timeout: nil,
|
249
|
+
retry_strategy: nil,
|
250
|
+
client_context: nil,
|
251
|
+
parent_span: nil)
|
252
|
+
super
|
253
|
+
yield self if block_given?
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
# Options for {QueryIndexManager#watch_indexes}
|
258
|
+
class WatchIndexes < ::Couchbase::Options::Base
|
259
|
+
attr_accessor :watch_primary # @return [Boolean]
|
260
|
+
|
261
|
+
# Creates an instance of options for {QueryIndexManager#watch_indexes}
|
262
|
+
#
|
263
|
+
# @param [Boolean] watch_primary whether or not to watch the primary index
|
264
|
+
# @param [Proc, nil] retry_strategy the custom retry strategy, if set
|
265
|
+
# @param [Hash, nil] client_context the client context data, if set
|
266
|
+
# @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
|
267
|
+
#
|
268
|
+
# @yieldparam [GetAllScopes] self
|
269
|
+
def initialize(watch_primary: false,
|
270
|
+
retry_strategy: nil,
|
271
|
+
client_context: nil,
|
272
|
+
parent_span: nil)
|
273
|
+
super(timeout: nil, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
|
274
|
+
@watch_primary = watch_primary
|
275
|
+
yield self if block_given?
|
276
|
+
end
|
277
|
+
|
278
|
+
# @api private
|
279
|
+
def to_backend
|
280
|
+
{
|
281
|
+
watch_primary: @watch_primary,
|
282
|
+
}
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
# rubocop:disable Naming/MethodName constructor shortcuts
|
287
|
+
module_function
|
288
|
+
|
289
|
+
# Construct {GetAllIndexes} options for {QueryIndexManager#get_all_indexes}
|
290
|
+
#
|
291
|
+
# @return [GetAllIndexes]
|
292
|
+
def GetAllIndexes(**args)
|
293
|
+
GetAllIndexes.new(**args)
|
294
|
+
end
|
295
|
+
|
296
|
+
# Construct {CreateIndex} options for {QueryIndexManager#create_index}
|
297
|
+
#
|
298
|
+
# @return [CreateIndex]
|
299
|
+
def CreateIndex(**args)
|
300
|
+
CreateIndex.new(**args)
|
301
|
+
end
|
302
|
+
|
303
|
+
# Construct {CreatePrimaryIndex} options for {QueryIndexManager#create_index}
|
304
|
+
#
|
305
|
+
# @return [CreatePrimaryIndex]
|
306
|
+
def CreatePrimaryIndex(**args)
|
307
|
+
CreatePrimaryIndex.new(**args)
|
308
|
+
end
|
309
|
+
|
310
|
+
# Construct {DropIndex} options for {QueryIndexManager#drop_index}
|
311
|
+
#
|
312
|
+
# @return [DropIndex]
|
313
|
+
def DropIndex(**args)
|
314
|
+
DropIndex.new(**args)
|
315
|
+
end
|
316
|
+
|
317
|
+
# Construct {DropPrimaryIndex} options for {QueryIndexManager#drop_primary_index}
|
318
|
+
#
|
319
|
+
# @return [DropPrimaryIndex]
|
320
|
+
def DropPrimaryIndex(**args)
|
321
|
+
DropPrimaryIndex.new(**args)
|
322
|
+
end
|
323
|
+
|
324
|
+
# rubocop:enable Naming/MethodName
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
328
|
+
class QueryIndexManager
|
329
|
+
alias inspect to_s
|
330
|
+
|
331
|
+
# @param [Couchbase::Backend] backend
|
332
|
+
def initialize(backend)
|
333
|
+
@backend = backend
|
334
|
+
end
|
335
|
+
|
336
|
+
# Fetches all indexes from the server
|
337
|
+
#
|
338
|
+
# @param [String] bucket_name name of the bucket
|
339
|
+
# @param [Options::Query::GetAllIndexes] options
|
340
|
+
#
|
341
|
+
# @return [Array<QueryIndex>]
|
342
|
+
#
|
343
|
+
# @raise [ArgumentError]
|
344
|
+
def get_all_indexes(bucket_name, options = GetAllIndexOptions.new)
|
345
|
+
res = @backend.query_index_get_all(bucket_name, options.to_backend)
|
346
|
+
res[:indexes].map do |idx|
|
347
|
+
QueryIndex.new do |index|
|
348
|
+
index.name = idx[:name]
|
349
|
+
index.is_primary = idx[:is_primary]
|
350
|
+
index.type = idx[:type]
|
351
|
+
index.state = idx[:state]
|
352
|
+
index.bucket = idx[:bucket_name]
|
353
|
+
index.scope = idx[:scope_name]
|
354
|
+
index.collection = idx[:collection_name]
|
355
|
+
index.index_key = idx[:index_key]
|
356
|
+
index.condition = idx[:condition]
|
357
|
+
index.partition = idx[:partition]
|
358
|
+
end
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
362
|
+
# Creates a new index
|
363
|
+
#
|
364
|
+
# @param [String] bucket_name name of the bucket
|
365
|
+
# @param [String] index_name name of the index
|
366
|
+
# @param [Array<String>] fields the lists of fields to create th index over
|
367
|
+
# @param [Options::Query::CreateIndex] options
|
368
|
+
#
|
369
|
+
# @return void
|
370
|
+
#
|
371
|
+
# @raise [ArgumentError]
|
372
|
+
# @raise [Error::IndexExists]
|
373
|
+
def create_index(bucket_name, index_name, fields, options = Options::Query::CreateIndex.new)
|
374
|
+
@backend.query_index_create(bucket_name, index_name, fields, options.to_backend)
|
375
|
+
end
|
376
|
+
|
377
|
+
# Creates new primary index
|
378
|
+
#
|
379
|
+
# @param [String] bucket_name name of the bucket
|
380
|
+
# @param [Options::Query::CreatePrimaryIndex] options
|
381
|
+
#
|
382
|
+
# @return void
|
383
|
+
#
|
384
|
+
# @raise [ArgumentError]
|
385
|
+
# @raise [Error::IndexExists]
|
386
|
+
def create_primary_index(bucket_name, options = Options::Query::CreatePrimaryIndex.new)
|
387
|
+
@backend.query_index_create_primary(bucket_name, options.to_backend)
|
388
|
+
end
|
389
|
+
|
390
|
+
# Drops the index
|
391
|
+
#
|
392
|
+
# @param [String] bucket_name name of the bucket
|
393
|
+
# @param [String] index_name name of the index
|
394
|
+
# @param [Options::Query::DropIndex] options
|
395
|
+
#
|
396
|
+
# @return void
|
397
|
+
#
|
398
|
+
# @raise [ArgumentError]
|
399
|
+
# @raise [Error::IndexNotFound]
|
400
|
+
def drop_index(bucket_name, index_name, options = Options::Query::DropIndex.new)
|
401
|
+
@backend.query_index_drop(bucket_name, index_name, options.to_backend)
|
402
|
+
true
|
403
|
+
end
|
404
|
+
|
405
|
+
# Drops the primary index
|
406
|
+
#
|
407
|
+
# @param [String] bucket_name name of the bucket
|
408
|
+
# @param [Options::Query::DropPrimaryIndex] options
|
409
|
+
#
|
410
|
+
# @return void
|
411
|
+
#
|
412
|
+
# @raise [ArgumentError]
|
413
|
+
# @raise [Error::IndexNotFound]
|
414
|
+
def drop_primary_index(bucket_name, options = Options::Query::DropPrimaryIndex.new)
|
415
|
+
@backend.query_index_drop_primary(bucket_name, options.to_backend)
|
416
|
+
true
|
417
|
+
end
|
418
|
+
|
419
|
+
# Build all indexes which are currently in deferred state
|
420
|
+
#
|
421
|
+
# @param [String] bucket_name name of the bucket
|
422
|
+
# @param [Options::Query::BuildDeferredIndexes] options
|
423
|
+
#
|
424
|
+
# @return void
|
425
|
+
#
|
426
|
+
# @raise [ArgumentError]
|
427
|
+
def build_deferred_indexes(bucket_name, options = Options::Query::BuildDeferredIndexes.new)
|
428
|
+
@backend.query_index_build_deferred(bucket_name, options.to_backend)
|
429
|
+
end
|
430
|
+
|
431
|
+
# Polls indexes until they are online
|
432
|
+
#
|
433
|
+
# @param [String] bucket_name name of the bucket
|
434
|
+
# @param [Array<String>] index_names names of the indexes to watch
|
435
|
+
# @param [Integer, #in_milliseconds] timeout the time in milliseconds allowed for the operation to complete
|
436
|
+
# @param [Options::Query::WatchIndexes] options
|
437
|
+
#
|
438
|
+
# @raise [ArgumentError]
|
439
|
+
# @raise [Error::IndexNotFound]
|
440
|
+
def watch_indexes(bucket_name, index_names, timeout, options = Options::Query::WatchIndexes.new)
|
441
|
+
@backend.query_index_watch(bucket_name, index_names, Utils::Time.extract_duration(timeout), options.to_backend)
|
442
|
+
end
|
443
|
+
|
444
|
+
# @api private
|
445
|
+
# TODO: deprecate after 3.2
|
446
|
+
GetAllIndexOptions = ::Couchbase::Management::Options::Query::GetAllIndexes
|
447
|
+
|
448
|
+
# @api private
|
449
|
+
# TODO: deprecate after 3.2
|
450
|
+
CreateIndexOptions = ::Couchbase::Management::Options::Query::CreateIndex
|
451
|
+
|
452
|
+
# @api private
|
453
|
+
# TODO: deprecate after 3.2
|
454
|
+
CreatePrimaryIndexOptions = ::Couchbase::Management::Options::Query::CreatePrimaryIndex
|
455
|
+
|
456
|
+
# @api private
|
457
|
+
# TODO: deprecate after 3.2
|
458
|
+
DropIndexOptions = ::Couchbase::Management::Options::Query::DropIndex
|
459
|
+
|
460
|
+
# @api private
|
461
|
+
# TODO: deprecate after 3.2
|
462
|
+
DropPrimaryIndexOptions = ::Couchbase::Management::Options::Query::DropPrimaryIndex
|
463
|
+
|
464
|
+
# @api private
|
465
|
+
# TODO: deprecate after 3.2
|
466
|
+
BuildDeferredIndexOptions = ::Couchbase::Management::Options::Query::BuildDeferredIndexes
|
467
|
+
|
468
|
+
# @api private
|
469
|
+
# TODO: deprecate after 3.2
|
470
|
+
WatchIndexesOptions = ::Couchbase::Management::Options::Query::WatchIndexes
|
471
|
+
end
|
472
|
+
|
473
|
+
class QueryIndex
|
474
|
+
# @return [String] name of the index
|
475
|
+
attr_accessor :name
|
476
|
+
|
477
|
+
# @return [Boolean] true if this is a primary index
|
478
|
+
attr_accessor :is_primary
|
479
|
+
alias primary? is_primary
|
480
|
+
|
481
|
+
# @return [:gsi, :view] type of the index
|
482
|
+
attr_accessor :type
|
483
|
+
|
484
|
+
# @return [Symbol] state
|
485
|
+
attr_accessor :state
|
486
|
+
|
487
|
+
# @return [String, nil] the name of the bucket
|
488
|
+
attr_accessor :bucket
|
489
|
+
|
490
|
+
# @return [String, nil] the name of the scope
|
491
|
+
attr_accessor :scope
|
492
|
+
|
493
|
+
# @return [String, nil] the name of the collection
|
494
|
+
attr_accessor :collection
|
495
|
+
|
496
|
+
# @return [Array<String>] an array of Strings that represent the index key(s). The array is empty in the case of a
|
497
|
+
# PRIMARY INDEX.
|
498
|
+
#
|
499
|
+
# @note the query service can present the key in a slightly different manner from when you declared the index: for
|
500
|
+
# instance, it will show the indexed fields in an escaped format (surrounded by backticks).
|
501
|
+
attr_accessor :index_key
|
502
|
+
|
503
|
+
# @return [String] the string representation of the index's condition (the WHERE clause of the index),
|
504
|
+
# or an empty Optional if no condition was set.
|
505
|
+
#
|
506
|
+
# @note that the query service can present the condition in a slightly different manner from when you declared the
|
507
|
+
# index. For instance it will wrap expressions with parentheses and show the fields in an escaped format
|
508
|
+
# (surrounded by backticks).
|
509
|
+
attr_accessor :condition
|
510
|
+
|
511
|
+
# @return [String] the string representation of the index's partition
|
512
|
+
attr_accessor :partition
|
513
|
+
|
514
|
+
# @yieldparam [QueryIndex] self
|
515
|
+
def initialize
|
516
|
+
yield self if block_given?
|
517
|
+
end
|
518
|
+
end
|
519
|
+
end
|
520
|
+
end
|