couchbase 3.4.0-arm64-darwin-20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +202 -0
  3. data/README.md +154 -0
  4. data/ext/extconf.rb +0 -0
  5. data/lib/active_support/cache/couchbase_store.rb +339 -0
  6. data/lib/couchbase/analytics_options.rb +107 -0
  7. data/lib/couchbase/authenticator.rb +65 -0
  8. data/lib/couchbase/binary_collection.rb +128 -0
  9. data/lib/couchbase/binary_collection_options.rb +24 -0
  10. data/lib/couchbase/bucket.rb +144 -0
  11. data/lib/couchbase/cluster.rb +439 -0
  12. data/lib/couchbase/cluster_registry.rb +44 -0
  13. data/lib/couchbase/collection.rb +589 -0
  14. data/lib/couchbase/collection_options.rb +300 -0
  15. data/lib/couchbase/config_profiles.rb +55 -0
  16. data/lib/couchbase/configuration.rb +57 -0
  17. data/lib/couchbase/datastructures/couchbase_list.rb +160 -0
  18. data/lib/couchbase/datastructures/couchbase_map.rb +194 -0
  19. data/lib/couchbase/datastructures/couchbase_queue.rb +134 -0
  20. data/lib/couchbase/datastructures/couchbase_set.rb +128 -0
  21. data/lib/couchbase/datastructures.rb +24 -0
  22. data/lib/couchbase/diagnostics.rb +181 -0
  23. data/lib/couchbase/errors.rb +351 -0
  24. data/lib/couchbase/json_transcoder.rb +32 -0
  25. data/lib/couchbase/libcouchbase.bundle +0 -0
  26. data/lib/couchbase/logger.rb +85 -0
  27. data/lib/couchbase/management/analytics_index_manager.rb +1127 -0
  28. data/lib/couchbase/management/bucket_manager.rb +436 -0
  29. data/lib/couchbase/management/collection_manager.rb +321 -0
  30. data/lib/couchbase/management/query_index_manager.rb +520 -0
  31. data/lib/couchbase/management/search_index_manager.rb +408 -0
  32. data/lib/couchbase/management/user_manager.rb +468 -0
  33. data/lib/couchbase/management/view_index_manager.rb +237 -0
  34. data/lib/couchbase/management.rb +27 -0
  35. data/lib/couchbase/mutation_state.rb +63 -0
  36. data/lib/couchbase/options.rb +2580 -0
  37. data/lib/couchbase/query_options.rb +120 -0
  38. data/lib/couchbase/railtie.rb +45 -0
  39. data/lib/couchbase/scope.rb +232 -0
  40. data/lib/couchbase/search_options.rb +1570 -0
  41. data/lib/couchbase/subdoc.rb +290 -0
  42. data/lib/couchbase/utils/generic_logger_adapter.rb +38 -0
  43. data/lib/couchbase/utils/stdlib_logger_adapter.rb +65 -0
  44. data/lib/couchbase/utils/time.rb +56 -0
  45. data/lib/couchbase/utils.rb +21 -0
  46. data/lib/couchbase/version.rb +23 -0
  47. data/lib/couchbase/view_options.rb +65 -0
  48. data/lib/couchbase.rb +20 -0
  49. data/lib/rails/generators/couchbase/config/config_generator.rb +27 -0
  50. metadata +101 -0
@@ -0,0 +1,321 @@
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 "rubygems/deprecate"
16
+
17
+ require "couchbase/errors"
18
+ require "couchbase/options"
19
+
20
+ module Couchbase
21
+ module Management
22
+ module Options
23
+ module Collection
24
+ # Options for {CollectionManager#get_all_scopes}
25
+ class GetAllScopes < ::Couchbase::Options::Base
26
+ # Creates an instance of options for {CollectionManager#get_all_scopes}
27
+ #
28
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
29
+ # @param [Proc, nil] retry_strategy the custom retry strategy, if set
30
+ # @param [Hash, nil] client_context the client context data, if set
31
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
32
+ #
33
+ # @yieldparam [GetAllScopes] self
34
+ def initialize(timeout: nil,
35
+ retry_strategy: nil,
36
+ client_context: nil,
37
+ parent_span: nil)
38
+ super
39
+ yield self if block_given?
40
+ end
41
+ end
42
+
43
+ # Options for {CollectionManager#create_scope}
44
+ class CreateScope < ::Couchbase::Options::Base
45
+ # Creates an instance of options for {CollectionManager#create_scope}
46
+ #
47
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
48
+ # @param [Proc, nil] retry_strategy the custom retry strategy, if set
49
+ # @param [Hash, nil] client_context the client context data, if set
50
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
51
+ #
52
+ # @yieldparam [CreateScope] self
53
+ def initialize(timeout: nil,
54
+ retry_strategy: nil,
55
+ client_context: nil,
56
+ parent_span: nil)
57
+ super
58
+ yield self if block_given?
59
+ end
60
+ end
61
+
62
+ # Options for {CollectionManager#drop_scope}
63
+ class DropScope < ::Couchbase::Options::Base
64
+ # Creates an instance of options for {CollectionManager#drop_scope}
65
+ #
66
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
67
+ # @param [Proc, nil] retry_strategy the custom retry strategy, if set
68
+ # @param [Hash, nil] client_context the client context data, if set
69
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
70
+ #
71
+ # @yieldparam [DropScope] self
72
+ def initialize(timeout: nil,
73
+ retry_strategy: nil,
74
+ client_context: nil,
75
+ parent_span: nil)
76
+ super
77
+ yield self if block_given?
78
+ end
79
+ end
80
+
81
+ # Options for {CollectionManager#create_collection}
82
+ class CreateCollection < ::Couchbase::Options::Base
83
+ # Creates an instance of options for {CollectionManager#create_collection}
84
+ #
85
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
86
+ # @param [Proc, nil] retry_strategy the custom retry strategy, if set
87
+ # @param [Hash, nil] client_context the client context data, if set
88
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
89
+ #
90
+ # @yieldparam [CreateCollection] self
91
+ def initialize(timeout: nil,
92
+ retry_strategy: nil,
93
+ client_context: nil,
94
+ parent_span: nil)
95
+ super
96
+ yield self if block_given?
97
+ end
98
+ end
99
+
100
+ # Options for {CollectionManager#drop_collection}
101
+ class DropCollection < ::Couchbase::Options::Base
102
+ # Creates an instance of options for {CollectionManager#drop_collection}
103
+ #
104
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
105
+ # @param [Proc, nil] retry_strategy the custom retry strategy, if set
106
+ # @param [Hash, nil] client_context the client context data, if set
107
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
108
+ #
109
+ # @yieldparam [DropCollection] self
110
+ def initialize(timeout: nil,
111
+ retry_strategy: nil,
112
+ client_context: nil,
113
+ parent_span: nil)
114
+ super
115
+ yield self if block_given?
116
+ end
117
+ end
118
+
119
+ # rubocop:disable Naming/MethodName constructor shortcuts
120
+ module_function
121
+
122
+ # Construct {GetAllScopes} options for {CollectionManager#get_all_scopes}
123
+ #
124
+ # @return [GetAllScopes]
125
+ def GetAllScopes(**args)
126
+ GetAllScopes.new(**args)
127
+ end
128
+
129
+ # Construct {CreateScope} options for {CollectionManager#create_scope}
130
+ #
131
+ # @return [CreateScope]
132
+ def CreateScope(**args)
133
+ CreateScope.new(**args)
134
+ end
135
+
136
+ # Construct {DropScope} options for {CollectionManager#drop_scope}
137
+ #
138
+ # @return [DropScope]
139
+ def DropScope(**args)
140
+ DropScope.new(**args)
141
+ end
142
+
143
+ # Construct {CreateCollection} options for {CollectionManager#create_collection}
144
+ #
145
+ # @return [CreateCollection]
146
+ def CreateCollection(**args)
147
+ CreateCollection.new(**args)
148
+ end
149
+
150
+ # Construct {DropCollection} options for {CollectionManager#drop_collection}
151
+ #
152
+ # @return [DropCollection]
153
+ def DropCollection(**args)
154
+ DropCollection.new(**args)
155
+ end
156
+
157
+ # rubocop:enable Naming/MethodName
158
+ end
159
+ end
160
+
161
+ class CollectionManager
162
+ extend Gem::Deprecate
163
+
164
+ alias inspect to_s
165
+
166
+ # @param [Couchbase::Backend] backend
167
+ # @param [String] bucket_name
168
+ def initialize(backend, bucket_name)
169
+ @backend = backend
170
+ @bucket_name = bucket_name
171
+ end
172
+
173
+ # Get all scopes
174
+ #
175
+ # @param [Options::Collection::GetAllScopes] options
176
+ #
177
+ # @return [Array<ScopeSpec>]
178
+ def get_all_scopes(options = Options::Collection::GetAllScopes.new)
179
+ res = @backend.scope_get_all(@bucket_name, options.to_backend)
180
+ res[:scopes].map do |s|
181
+ ScopeSpec.new do |scope|
182
+ scope.name = s[:name]
183
+ scope.collections = s[:collections].map do |c|
184
+ CollectionSpec.new do |collection|
185
+ collection.name = c[:name]
186
+ collection.scope_name = s[:name]
187
+ end
188
+ end
189
+ end
190
+ end
191
+ end
192
+
193
+ # Get a scope by name
194
+ #
195
+ # @param [String] scope_name name of the scope
196
+ # @param [GetScopeOptions] options
197
+ #
198
+ # @deprecated Use {#get_all_scopes} with filter by name
199
+ #
200
+ # @return [ScopeSpec]
201
+ #
202
+ # @raise [Error::ScopeNotFound]
203
+ def get_scope(scope_name, options = GetScopeOptions.new)
204
+ get_all_scopes(Options::Collection::GetAllScopes(timeout: options.timeout))
205
+ .find { |scope| scope.name == scope_name } or raise Error::ScopeNotFound, "unable to find scope #{scope_name}"
206
+ end
207
+
208
+ deprecate :get_scope, :get_all_scopes, 2021, 6
209
+
210
+ # Creates a new scope
211
+ #
212
+ # @param [String] scope_name name of the scope
213
+ # @param [Options::Collection::CreateScope] options
214
+ #
215
+ # @return void
216
+ #
217
+ # @raise [ArgumentError]
218
+ def create_scope(scope_name, options = Options::Collection::CreateScope.new)
219
+ @backend.scope_create(@bucket_name, scope_name, options.to_backend)
220
+ end
221
+
222
+ # Removes a scope
223
+ #
224
+ # @param [String] scope_name name of the scope
225
+ # @param [Options::Collection::DropScope] options
226
+ #
227
+ # @return void
228
+ #
229
+ # @raise [Error::ScopeNotFound]
230
+ def drop_scope(scope_name, options = Options::Collection::DropScope.new)
231
+ @backend.scope_drop(@bucket_name, scope_name, options.to_backend)
232
+ end
233
+
234
+ # Creates a new collection
235
+ #
236
+ # @param [CollectionSpec] collection specification of the collection
237
+ # @param [Options::Collection::CreateCollection] options
238
+ #
239
+ # @return void
240
+ #
241
+ # @raise [ArgumentError]
242
+ # @raise [Error::CollectionExist]
243
+ # @raise [Error::ScopeNotFound]
244
+ def create_collection(collection, options = Options::Collection::CreateCollection.new)
245
+ @backend.collection_create(@bucket_name, collection.scope_name, collection.name, collection.max_expiry, options.to_backend)
246
+ end
247
+
248
+ # Removes a collection
249
+ #
250
+ # @param [CollectionSpec] collection specification of the collection
251
+ # @param [Options::Collection::DropCollection] options
252
+ #
253
+ # @return void
254
+ #
255
+ # @raise [Error::CollectionNotFound]
256
+ def drop_collection(collection, options = Options::Collection::DropCollection.new)
257
+ @backend.collection_drop(@bucket_name, collection.scope_name, collection.name, options.to_backend)
258
+ end
259
+
260
+ # @deprecated use {CollectionManager#get_all_scopes} instead
261
+ class GetScopeOptions
262
+ # @return [Integer] the time in milliseconds allowed for the operation to complete
263
+ attr_accessor :timeout
264
+
265
+ # @yieldparam [GetScopeOptions] self
266
+ def initialize
267
+ yield self if block_given?
268
+ end
269
+ end
270
+
271
+ # @api private
272
+ # TODO: deprecate after 3.2
273
+ GetAllScopesOptions = ::Couchbase::Management::Options::Collection::GetAllScopes
274
+
275
+ # @api private
276
+ # TODO: deprecate after 3.2
277
+ CreateScopeOptions = ::Couchbase::Management::Options::Collection::CreateScope
278
+
279
+ # @api private
280
+ # TODO: deprecate after 3.2
281
+ DropScopeOptions = ::Couchbase::Management::Options::Collection::DropScope
282
+
283
+ # @api private
284
+ # TODO: deprecate after 3.2
285
+ CreateCollectionOptions = ::Couchbase::Management::Options::Collection::CreateCollection
286
+
287
+ # @api private
288
+ # TODO: deprecate after 3.2
289
+ DropCollectionOptions = ::Couchbase::Management::Options::Collection::DropCollection
290
+ end
291
+
292
+ class ScopeSpec
293
+ # @return [String] name of the scope
294
+ attr_accessor :name
295
+
296
+ # @return [Array<CollectionSpec>] list of collections associated with the scope
297
+ attr_accessor :collections
298
+
299
+ # @yieldparam [ScopeSpec] self
300
+ def initialize
301
+ yield self if block_given?
302
+ end
303
+ end
304
+
305
+ class CollectionSpec
306
+ # @return [String] name of the collection
307
+ attr_accessor :name
308
+
309
+ # @return [String] name of the scope
310
+ attr_accessor :scope_name
311
+
312
+ # @return [Integer] time in seconds of the expiration for new documents in the collection (set to +nil+ to disable it)
313
+ attr_accessor :max_expiry
314
+
315
+ # @yieldparam [CollectionSpec] self
316
+ def initialize
317
+ yield self if block_given?
318
+ end
319
+ end
320
+ end
321
+ end