couchbase 3.9.0-aarch64-linux-musl

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 (149) 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 +407 -0
  6. data/lib/couchbase/3.2/libcouchbase.so +0 -0
  7. data/lib/couchbase/3.3/libcouchbase.so +0 -0
  8. data/lib/couchbase/3.4/libcouchbase.so +0 -0
  9. data/lib/couchbase/4.0/libcouchbase.so +0 -0
  10. data/lib/couchbase/analytics_options.rb +109 -0
  11. data/lib/couchbase/authenticator.rb +80 -0
  12. data/lib/couchbase/binary_collection.rb +145 -0
  13. data/lib/couchbase/binary_collection_options.rb +26 -0
  14. data/lib/couchbase/bucket.rb +173 -0
  15. data/lib/couchbase/cluster.rb +555 -0
  16. data/lib/couchbase/cluster_registry.rb +49 -0
  17. data/lib/couchbase/collection.rb +770 -0
  18. data/lib/couchbase/collection_options.rb +401 -0
  19. data/lib/couchbase/config_profiles.rb +57 -0
  20. data/lib/couchbase/configuration.rb +58 -0
  21. data/lib/couchbase/datastructures/couchbase_list.rb +192 -0
  22. data/lib/couchbase/datastructures/couchbase_map.rb +231 -0
  23. data/lib/couchbase/datastructures/couchbase_queue.rb +161 -0
  24. data/lib/couchbase/datastructures/couchbase_set.rb +145 -0
  25. data/lib/couchbase/datastructures.rb +26 -0
  26. data/lib/couchbase/deprecations.rb +61 -0
  27. data/lib/couchbase/diagnostics.rb +183 -0
  28. data/lib/couchbase/errors.rb +438 -0
  29. data/lib/couchbase/fork_hooks.rb +41 -0
  30. data/lib/couchbase/get_replica_strategy.rb +89 -0
  31. data/lib/couchbase/json_transcoder.rb +41 -0
  32. data/lib/couchbase/key_value_scan.rb +119 -0
  33. data/lib/couchbase/libcouchbase.rb +6 -0
  34. data/lib/couchbase/logger.rb +87 -0
  35. data/lib/couchbase/management/analytics_index_manager.rb +1160 -0
  36. data/lib/couchbase/management/bucket_manager.rb +479 -0
  37. data/lib/couchbase/management/collection_manager.rb +515 -0
  38. data/lib/couchbase/management/collection_query_index_manager.rb +247 -0
  39. data/lib/couchbase/management/query_index_manager.rb +671 -0
  40. data/lib/couchbase/management/scope_search_index_manager.rb +267 -0
  41. data/lib/couchbase/management/search_index_manager.rb +649 -0
  42. data/lib/couchbase/management/user_manager.rb +639 -0
  43. data/lib/couchbase/management/view_index_manager.rb +332 -0
  44. data/lib/couchbase/management.rb +31 -0
  45. data/lib/couchbase/metrics/logging_meter.rb +108 -0
  46. data/lib/couchbase/metrics/logging_value_recorder.rb +50 -0
  47. data/lib/couchbase/metrics/meter.rb +27 -0
  48. data/lib/couchbase/metrics/noop_meter.rb +30 -0
  49. data/lib/couchbase/metrics/noop_value_recorder.rb +27 -0
  50. data/lib/couchbase/metrics/value_recorder.rb +25 -0
  51. data/lib/couchbase/mutation_state.rb +65 -0
  52. data/lib/couchbase/options.rb +3097 -0
  53. data/lib/couchbase/protostellar/binary_collection.rb +55 -0
  54. data/lib/couchbase/protostellar/bucket.rb +59 -0
  55. data/lib/couchbase/protostellar/client.rb +97 -0
  56. data/lib/couchbase/protostellar/cluster.rb +182 -0
  57. data/lib/couchbase/protostellar/collection.rb +156 -0
  58. data/lib/couchbase/protostellar/connect_options.rb +63 -0
  59. data/lib/couchbase/protostellar/error_handling.rb +204 -0
  60. data/lib/couchbase/protostellar/generated/admin/analytics/v1/analytics_pb.rb +54 -0
  61. data/lib/couchbase/protostellar/generated/admin/analytics/v1/analytics_services_pb.rb +51 -0
  62. data/lib/couchbase/protostellar/generated/admin/bucket/v1/bucket_pb.rb +42 -0
  63. data/lib/couchbase/protostellar/generated/admin/bucket/v1/bucket_services_pb.rb +51 -0
  64. data/lib/couchbase/protostellar/generated/admin/collection/v1/collection_pb.rb +38 -0
  65. data/lib/couchbase/protostellar/generated/admin/collection/v1/collection_services_pb.rb +52 -0
  66. data/lib/couchbase/protostellar/generated/admin/query/v1/query_pb.rb +42 -0
  67. data/lib/couchbase/protostellar/generated/admin/query/v1/query_services_pb.rb +55 -0
  68. data/lib/couchbase/protostellar/generated/admin/search/v1/search_pb.rb +51 -0
  69. data/lib/couchbase/protostellar/generated/admin/search/v1/search_services_pb.rb +67 -0
  70. data/lib/couchbase/protostellar/generated/analytics/v1/analytics_pb.rb +31 -0
  71. data/lib/couchbase/protostellar/generated/analytics/v1/analytics_services_pb.rb +40 -0
  72. data/lib/couchbase/protostellar/generated/internal/hooks/v1/hooks_pb.rb +51 -0
  73. data/lib/couchbase/protostellar/generated/internal/hooks/v1/hooks_services_pb.rb +54 -0
  74. data/lib/couchbase/protostellar/generated/internal/xdcr/v1/xdcr_pb.rb +46 -0
  75. data/lib/couchbase/protostellar/generated/internal/xdcr/v1/xdcr_services_pb.rb +56 -0
  76. data/lib/couchbase/protostellar/generated/kv/v1/kv_pb.rb +74 -0
  77. data/lib/couchbase/protostellar/generated/kv/v1/kv_services_pb.rb +93 -0
  78. data/lib/couchbase/protostellar/generated/query/v1/query_pb.rb +35 -0
  79. data/lib/couchbase/protostellar/generated/query/v1/query_services_pb.rb +40 -0
  80. data/lib/couchbase/protostellar/generated/routing/v2/routing_pb.rb +26 -0
  81. data/lib/couchbase/protostellar/generated/routing/v2/routing_services_pb.rb +43 -0
  82. data/lib/couchbase/protostellar/generated/search/v1/search_pb.rb +78 -0
  83. data/lib/couchbase/protostellar/generated/search/v1/search_services_pb.rb +41 -0
  84. data/lib/couchbase/protostellar/generated/transactions/v1/transactions_pb.rb +36 -0
  85. data/lib/couchbase/protostellar/generated/transactions/v1/transactions_services_pb.rb +66 -0
  86. data/lib/couchbase/protostellar/generated/view/v1/view_pb.rb +30 -0
  87. data/lib/couchbase/protostellar/generated/view/v1/view_services_pb.rb +39 -0
  88. data/lib/couchbase/protostellar/generated.rb +9 -0
  89. data/lib/couchbase/protostellar/management/bucket_manager.rb +67 -0
  90. data/lib/couchbase/protostellar/management/collection_manager.rb +94 -0
  91. data/lib/couchbase/protostellar/management/collection_query_index_manager.rb +124 -0
  92. data/lib/couchbase/protostellar/management/query_index_manager.rb +112 -0
  93. data/lib/couchbase/protostellar/management.rb +24 -0
  94. data/lib/couchbase/protostellar/request.rb +79 -0
  95. data/lib/couchbase/protostellar/request_behaviour.rb +42 -0
  96. data/lib/couchbase/protostellar/request_generator/admin/bucket.rb +124 -0
  97. data/lib/couchbase/protostellar/request_generator/admin/collection.rb +96 -0
  98. data/lib/couchbase/protostellar/request_generator/admin/query.rb +132 -0
  99. data/lib/couchbase/protostellar/request_generator/admin.rb +24 -0
  100. data/lib/couchbase/protostellar/request_generator/kv.rb +488 -0
  101. data/lib/couchbase/protostellar/request_generator/query.rb +133 -0
  102. data/lib/couchbase/protostellar/request_generator/search.rb +403 -0
  103. data/lib/couchbase/protostellar/request_generator.rb +26 -0
  104. data/lib/couchbase/protostellar/response_converter/admin/bucket.rb +55 -0
  105. data/lib/couchbase/protostellar/response_converter/admin/collection.rb +42 -0
  106. data/lib/couchbase/protostellar/response_converter/admin/query.rb +59 -0
  107. data/lib/couchbase/protostellar/response_converter/admin.rb +24 -0
  108. data/lib/couchbase/protostellar/response_converter/kv.rb +151 -0
  109. data/lib/couchbase/protostellar/response_converter/query.rb +84 -0
  110. data/lib/couchbase/protostellar/response_converter/search.rb +136 -0
  111. data/lib/couchbase/protostellar/response_converter.rb +26 -0
  112. data/lib/couchbase/protostellar/retry/action.rb +38 -0
  113. data/lib/couchbase/protostellar/retry/orchestrator.rb +61 -0
  114. data/lib/couchbase/protostellar/retry/reason.rb +67 -0
  115. data/lib/couchbase/protostellar/retry/strategies/best_effort.rb +49 -0
  116. data/lib/couchbase/protostellar/retry/strategies/fail_fast.rb +33 -0
  117. data/lib/couchbase/protostellar/retry/strategies.rb +27 -0
  118. data/lib/couchbase/protostellar/retry.rb +28 -0
  119. data/lib/couchbase/protostellar/scope.rb +61 -0
  120. data/lib/couchbase/protostellar/timeout_defaults.rb +30 -0
  121. data/lib/couchbase/protostellar/timeouts.rb +83 -0
  122. data/lib/couchbase/protostellar.rb +29 -0
  123. data/lib/couchbase/query_options.rb +122 -0
  124. data/lib/couchbase/railtie.rb +47 -0
  125. data/lib/couchbase/raw_binary_transcoder.rb +39 -0
  126. data/lib/couchbase/raw_json_transcoder.rb +40 -0
  127. data/lib/couchbase/raw_string_transcoder.rb +42 -0
  128. data/lib/couchbase/scope.rb +272 -0
  129. data/lib/couchbase/search_options.rb +1744 -0
  130. data/lib/couchbase/subdoc.rb +293 -0
  131. data/lib/couchbase/tracing/noop_span.rb +29 -0
  132. data/lib/couchbase/tracing/noop_tracer.rb +29 -0
  133. data/lib/couchbase/tracing/request_span.rb +34 -0
  134. data/lib/couchbase/tracing/request_tracer.rb +28 -0
  135. data/lib/couchbase/tracing/threshold_logging_span.rb +112 -0
  136. data/lib/couchbase/tracing/threshold_logging_tracer.rb +231 -0
  137. data/lib/couchbase/transcoder_flags.rb +64 -0
  138. data/lib/couchbase/utils/generic_logger_adapter.rb +40 -0
  139. data/lib/couchbase/utils/hdr_histogram.rb +55 -0
  140. data/lib/couchbase/utils/observability.rb +263 -0
  141. data/lib/couchbase/utils/observability_constants.rb +200 -0
  142. data/lib/couchbase/utils/stdlib_logger_adapter.rb +65 -0
  143. data/lib/couchbase/utils/time.rb +71 -0
  144. data/lib/couchbase/utils.rb +23 -0
  145. data/lib/couchbase/version.rb +25 -0
  146. data/lib/couchbase/view_options.rb +67 -0
  147. data/lib/couchbase.rb +32 -0
  148. data/lib/rails/generators/couchbase/config/config_generator.rb +29 -0
  149. metadata +228 -0
@@ -0,0 +1,479 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020-2021 Couchbase, Inc.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require "rubygems/deprecate"
18
+
19
+ require "couchbase/errors"
20
+ require "couchbase/options"
21
+
22
+ module Couchbase
23
+ module Management
24
+ module Options
25
+ module Bucket
26
+ # Options for {BucketManager#create_bucket}
27
+ class CreateBucket < ::Couchbase::Options::Base
28
+ # Creates an instance of options for {BucketManager#create_bucket}
29
+ #
30
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
31
+ # @param [Symbol, nil] retry_strategy ignored by this operation
32
+ # @param [Hash, nil] client_context the client context data, if set
33
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
34
+ #
35
+ # @yieldparam [CreateBucket] self
36
+ def initialize(timeout: nil,
37
+ retry_strategy: nil,
38
+ client_context: nil,
39
+ parent_span: nil)
40
+ super
41
+ yield self if block_given?
42
+ end
43
+ end
44
+
45
+ # Options for {BucketManager#update_bucket}
46
+ class UpdateBucket < ::Couchbase::Options::Base
47
+ # Creates an instance of options for {BucketManager#update_bucket}
48
+ #
49
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
50
+ # @param [Symbol, nil] retry_strategy ignored by this operation
51
+ # @param [Hash, nil] client_context the client context data, if set
52
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
53
+ #
54
+ # @yieldparam [UpdateBucket] self
55
+ def initialize(timeout: nil,
56
+ retry_strategy: nil,
57
+ client_context: nil,
58
+ parent_span: nil)
59
+ super
60
+ yield self if block_given?
61
+ end
62
+ end
63
+
64
+ # Options for {BucketManager#drop_bucket}
65
+ class DropBucket < ::Couchbase::Options::Base
66
+ # Creates an instance of options for {BucketManager#drop_bucket}
67
+ #
68
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
69
+ # @param [Symbol, nil] retry_strategy ignored by this operation
70
+ # @param [Hash, nil] client_context the client context data, if set
71
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
72
+ #
73
+ # @yieldparam [DropBucket] self
74
+ def initialize(timeout: nil,
75
+ retry_strategy: nil,
76
+ client_context: nil,
77
+ parent_span: nil)
78
+ super
79
+ yield self if block_given?
80
+ end
81
+ end
82
+
83
+ # Options for {BucketManager#get_bucket}
84
+ class GetBucket < ::Couchbase::Options::Base
85
+ # Creates an instance of options for {BucketManager#get_bucket}
86
+ #
87
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
88
+ # @param [Symbol, nil] retry_strategy ignored by this operation
89
+ # @param [Hash, nil] client_context the client context data, if set
90
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
91
+ #
92
+ # @yieldparam [GetBucket] self
93
+ def initialize(timeout: nil,
94
+ retry_strategy: nil,
95
+ client_context: nil,
96
+ parent_span: nil)
97
+ super
98
+ yield self if block_given?
99
+ end
100
+ end
101
+
102
+ # Options for {BucketManager#get_all_buckets}
103
+ class GetAllBuckets < ::Couchbase::Options::Base
104
+ # Creates an instance of options for {BucketManager#get_all_buckets}
105
+ #
106
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
107
+ # @param [Symbol, nil] retry_strategy ignored by this operation
108
+ # @param [Hash, nil] client_context the client context data, if set
109
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
110
+ #
111
+ # @yieldparam [GetAllBuckets] self
112
+ def initialize(timeout: nil,
113
+ retry_strategy: nil,
114
+ client_context: nil,
115
+ parent_span: nil)
116
+ super
117
+ yield self if block_given?
118
+ end
119
+ end
120
+
121
+ # Options for {BucketManager#flush_bucket}
122
+ class FlushBucket < ::Couchbase::Options::Base
123
+ # Creates an instance of options for {BucketManager#flush_bucket}
124
+ #
125
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
126
+ # @param [Symbol, nil] retry_strategy ignored by this operation
127
+ # @param [Hash, nil] client_context the client context data, if set
128
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
129
+ #
130
+ # @yieldparam [FlushBucket] self
131
+ def initialize(timeout: nil,
132
+ retry_strategy: nil,
133
+ client_context: nil,
134
+ parent_span: nil)
135
+ super
136
+ yield self if block_given?
137
+ end
138
+ end
139
+
140
+ # rubocop:disable Naming/MethodName -- constructor shortcuts
141
+ module_function
142
+
143
+ # Construct {CreateBucket} options for {BucketManager#create_bucket}
144
+ #
145
+ # @return [CreateBucket]
146
+ def CreateBucket(**args)
147
+ CreateBucket.new(**args)
148
+ end
149
+
150
+ # Construct {UpdateBucket} options for {BucketManager#update_bucket}
151
+ #
152
+ # @return [UpdateBucket]
153
+ def UpdateBucket(**args)
154
+ UpdateBucket.new(**args)
155
+ end
156
+
157
+ # Construct {DropBucket} options for {BucketManager#drop_bucket}
158
+ #
159
+ # @return [DropBucket]
160
+ def DropBucket(**args)
161
+ DropBucket.new(**args)
162
+ end
163
+
164
+ # Construct {GetBucket} options for {BucketManager#get_bucket}
165
+ #
166
+ # @return [GetBucket]
167
+ def GetBucket(**args)
168
+ GetBucket.new(**args)
169
+ end
170
+
171
+ # Construct {GetAllBuckets} options for {BucketManager#get_all_buckets}
172
+ #
173
+ # @return [GetAllBuckets]
174
+ def GetAllBuckets(**args)
175
+ GetAllBuckets.new(**args)
176
+ end
177
+
178
+ # Construct {FlushBucket} options for {BucketManager#flush_bucket}
179
+ #
180
+ # @return [FlushBucket]
181
+ def FlushBucket(**args)
182
+ FlushBucket.new(**args)
183
+ end
184
+
185
+ # rubocop:enable Naming/MethodName
186
+ end
187
+ end
188
+
189
+ class BucketManager
190
+ alias inspect to_s
191
+
192
+ # @param [Couchbase::Backend] backend
193
+ # @param [Couchbase::Observability::Wrapper] observability wrapper
194
+ #
195
+ # @api private
196
+ def initialize(backend, observability)
197
+ @backend = backend
198
+ @observability = observability
199
+ end
200
+
201
+ # Creates new bucket
202
+ #
203
+ # @param [BucketSettings] settings bucket settings
204
+ # @param [Options::Bucket::CreateBucket] options
205
+ #
206
+ # @return void
207
+ #
208
+ # @raise [ArgumentError]
209
+ # @raise [Error::BucketExists]
210
+ def create_bucket(settings, options = Options::Bucket::CreateBucket.new)
211
+ @observability.record_operation(Observability::OP_BM_CREATE_BUCKET, options.parent_span, self, :management) do |obs_handler|
212
+ obs_handler.add_bucket_name(settings.name)
213
+
214
+ @backend.bucket_create(
215
+ {
216
+ name: settings.name,
217
+ flush_enabled: settings.flush_enabled,
218
+ ram_quota_mb: settings.ram_quota_mb,
219
+ num_replicas: settings.num_replicas,
220
+ replica_indexes: settings.replica_indexes,
221
+ bucket_type: settings.bucket_type,
222
+ eviction_policy: settings.eviction_policy,
223
+ max_expiry: settings.max_expiry,
224
+ compression_mode: settings.compression_mode,
225
+ minimum_durability_level: settings.minimum_durability_level,
226
+ conflict_resolution_type: settings.conflict_resolution_type,
227
+ storage_backend: settings.storage_backend,
228
+ history_retention_collection_default: settings.history_retention_collection_default,
229
+ history_retention_duration: settings.history_retention_duration,
230
+ history_retention_bytes: settings.history_retention_bytes,
231
+ num_vbuckets: settings.num_vbuckets,
232
+ },
233
+ options.to_backend,
234
+ obs_handler,
235
+ )
236
+ end
237
+ end
238
+
239
+ # Updates the bucket settings
240
+ #
241
+ # @param [BucketSettings] settings bucket settings
242
+ # @param [Options::Bucket::UpdateBucket] options
243
+ #
244
+ # @return void
245
+ #
246
+ # @raise [ArgumentError]
247
+ # @raise [Error::BucketNotFound]
248
+ def update_bucket(settings, options = Options::Bucket::UpdateBucket.new)
249
+ @observability.record_operation(Observability::OP_BM_UPDATE_BUCKET, options.parent_span, self, :management) do |obs_handler|
250
+ obs_handler.add_bucket_name(settings.name)
251
+
252
+ @backend.bucket_update(
253
+ {
254
+ name: settings.name,
255
+ flush_enabled: settings.flush_enabled,
256
+ ram_quota_mb: settings.ram_quota_mb,
257
+ num_replicas: settings.num_replicas,
258
+ replica_indexes: settings.replica_indexes,
259
+ bucket_type: settings.bucket_type,
260
+ eviction_policy: settings.eviction_policy,
261
+ max_expiry: settings.max_expiry,
262
+ compression_mode: settings.compression_mode,
263
+ minimum_durability_level: settings.minimum_durability_level,
264
+ storage_backend: settings.storage_backend,
265
+ history_retention_collection_default: settings.history_retention_collection_default,
266
+ history_retention_bytes: settings.history_retention_bytes,
267
+ history_retention_duration: settings.history_retention_duration,
268
+ num_vbuckets: settings.num_vbuckets,
269
+ },
270
+ options.to_backend,
271
+ obs_handler,
272
+ )
273
+ end
274
+ end
275
+
276
+ # Removes a bucket
277
+ #
278
+ # @param [String] bucket_name name of the bucket
279
+ # @param [Options::Bucket::DropBucket] options
280
+ #
281
+ # @return void
282
+ #
283
+ # @raise [ArgumentError]
284
+ # @raise [Error::BucketNotFound]
285
+ def drop_bucket(bucket_name, options = Options::Bucket::DropBucket.new)
286
+ @observability.record_operation(Observability::OP_BM_DROP_BUCKET, options.parent_span, self, :management) do |obs_handler|
287
+ obs_handler.add_bucket_name(bucket_name)
288
+
289
+ @backend.bucket_drop(bucket_name, options.to_backend, obs_handler)
290
+ end
291
+ end
292
+
293
+ # Fetch settings of the bucket
294
+ #
295
+ # @param [String] bucket_name name of the bucket
296
+ # @param [Options::Bucket::GetBucket] options
297
+ #
298
+ # @return [BucketSettings]
299
+ #
300
+ # @raise [ArgumentError]
301
+ # @raise [Error::BucketNotFound]
302
+ def get_bucket(bucket_name, options = Options::Bucket::GetBucket.new)
303
+ @observability.record_operation(Observability::OP_BM_GET_BUCKET, options.parent_span, self, :management) do |obs_handler|
304
+ obs_handler.add_bucket_name(bucket_name)
305
+
306
+ extract_bucket_settings(@backend.bucket_get(bucket_name, options.to_backend, obs_handler))
307
+ end
308
+ end
309
+
310
+ # Get settings for all buckets
311
+ #
312
+ # @param [Options::Bucket::GetAllBuckets] options
313
+ # @return [Array<BucketSettings>]
314
+ def get_all_buckets(options = Options::Bucket::GetAllBuckets.new)
315
+ @observability.record_operation(Observability::OP_BM_GET_ALL_BUCKETS, options.parent_span, self, :management) do |obs_handler|
316
+ @backend.bucket_get_all(options.to_backend, obs_handler)
317
+ .map { |entry| extract_bucket_settings(entry) }
318
+ end
319
+ end
320
+
321
+ # @param [String] bucket_name name of the bucket
322
+ # @param [Options::Bucket::FlushBucket] options
323
+ #
324
+ # @return void
325
+ #
326
+ # @raise [ArgumentError]
327
+ # @raise [Error::BucketNotFound]
328
+ # @raise [Error::BucketNotFlushable]
329
+ def flush_bucket(bucket_name, options = Options::Bucket::FlushBucket.new)
330
+ @observability.record_operation(Observability::OP_BM_FLUSH_BUCKET, options.parent_span, self, :management) do |obs_handler|
331
+ @backend.bucket_flush(bucket_name, options.to_backend, obs_handler)
332
+ end
333
+ end
334
+
335
+ # @api private
336
+ # TODO: deprecate after 3.2
337
+ CreateBucketOptions = ::Couchbase::Management::Options::Bucket::CreateBucket
338
+
339
+ # @api private
340
+ # TODO: deprecate after 3.2
341
+ UpdateBucketOptions = ::Couchbase::Management::Options::Bucket::UpdateBucket
342
+
343
+ # @api private
344
+ # TODO: deprecate after 3.2
345
+ DropBucketOptions = ::Couchbase::Management::Options::Bucket::DropBucket
346
+
347
+ # @api private
348
+ # TODO: deprecate after 3.2
349
+ GetBucketOptions = ::Couchbase::Management::Options::Bucket::GetBucket
350
+
351
+ # @api private
352
+ # TODO: deprecate after 3.2
353
+ GetAllBucketsOptions = ::Couchbase::Management::Options::Bucket::GetAllBuckets
354
+
355
+ # @api private
356
+ # TODO: deprecate after 3.2
357
+ FlushBucketOptions = ::Couchbase::Management::Options::Bucket::FlushBucket
358
+
359
+ private
360
+
361
+ def extract_bucket_settings(entry)
362
+ BucketSettings.new do |bucket|
363
+ bucket.name = entry[:name]
364
+ bucket.flush_enabled = entry[:flush_enabled]
365
+ bucket.ram_quota_mb = entry[:ram_quota_mb]
366
+ bucket.num_replicas = entry[:num_replicas]
367
+ bucket.replica_indexes = entry[:replica_indexes]
368
+ bucket.bucket_type = entry[:bucket_type]
369
+ bucket.max_expiry = entry[:max_expiry]
370
+ bucket.eviction_policy = entry[:eviction_policy]
371
+ bucket.minimum_durability_level = entry[:minimum_durability_level]
372
+ bucket.compression_mode = entry[:compression_mode]
373
+ bucket.instance_variable_set(:@healthy, entry[:nodes].all? { |node| node[:status] == "healthy" })
374
+ bucket.storage_backend = entry[:storage_backend]
375
+ bucket.history_retention_collection_default = entry[:history_retention_collection_default]
376
+ bucket.history_retention_bytes = entry[:history_retention_bytes]
377
+ bucket.history_retention_duration = entry[:history_retention_duration]
378
+ bucket.num_vbuckets = entry[:num_vbuckets]
379
+ end
380
+ end
381
+ end
382
+
383
+ class BucketSettings
384
+ extend Gem::Deprecate
385
+
386
+ # @return [String] name of the bucket
387
+ attr_accessor :name
388
+
389
+ # @return [Boolean] whether or not flush should be enabled on the bucket. Defaults to false.
390
+ attr_accessor :flush_enabled
391
+
392
+ # @return [Integer] RAM quota in megabytes for the bucket
393
+ attr_accessor :ram_quota_mb
394
+
395
+ # @return [Integer] number of replicas for documents
396
+ attr_accessor :num_replicas
397
+
398
+ # @return [Boolean] whether replica indexes should be enabled for the bucket
399
+ attr_accessor :replica_indexes
400
+
401
+ # @return [:couchbase, :memcached, :ephemeral] the type of the bucket. Defaults to +:couchbase+
402
+ attr_accessor :bucket_type
403
+
404
+ # @return [nil, :couchstore, :magma] the type of the storage backend of the bucket
405
+ attr_accessor :storage_backend
406
+
407
+ # Eviction policy to use
408
+ #
409
+ # :full:: During ejection, only the value will be ejected (key and metadata will remain in memory). Value Ejection
410
+ # needs more system memory, but provides better performance than Full Ejection. This value is only valid for
411
+ # buckets of type +:couchbase+.
412
+ #
413
+ # :value_only:: During ejection, everything (including key, metadata, and value) will be ejected. Full Ejection
414
+ # reduces the memory overhead requirement, at the cost of performance. This value is only valid for
415
+ # buckets of type +:couchbase+.
416
+ #
417
+ # :no_eviction:: Couchbase Server keeps all data until explicitly deleted, but will reject any new data if you
418
+ # reach the quota (dedicated memory) you set for your bucket. This value is only valid for buckets
419
+ # of type +:ephemeral+.
420
+ #
421
+ # :not_recently_used:: When the memory quota is reached, Couchbase Server ejects data that has not been used
422
+ # recently. This value is only valid for buckets of type +:ephemeral+.
423
+ #
424
+ # @return [:full, :value_only, :no_eviction, :not_recently_used] the eviction policy to use
425
+ attr_accessor :eviction_policy
426
+
427
+ # @return [Integer] value of TTL (expiration) in seconds for new documents created without expiration
428
+ attr_accessor :max_expiry
429
+
430
+ # @return [:off, :passive, :active] the compression mode to use
431
+ attr_accessor :compression_mode
432
+
433
+ # @return [:timestamp, :sequence_number, :custom] conflict resolution policy
434
+ attr_accessor :conflict_resolution_type
435
+
436
+ # @return [nil, :none, :majority, :majority_and_persist_to_active, :persist_to_majority] the minimum durability level
437
+ attr_accessor :minimum_durability_level
438
+
439
+ # @return [Boolean, nil] whether to enable history retention on collections by default
440
+ attr_accessor :history_retention_collection_default
441
+
442
+ # @return [Integer, nil] the maximum size, in bytes, of the change history that is written to disk for all
443
+ # collections in this bucket
444
+ attr_accessor :history_retention_bytes
445
+
446
+ # @return [Integer, nil] the maximum duration, in seconds, to be covered by the change history that is written to disk for all
447
+ # collections in this bucket
448
+ attr_accessor :history_retention_duration
449
+
450
+ # @return [Integer, nil] the number of vBuckets the bucket should have. If not set, the server default will be used
451
+ attr_accessor :num_vbuckets
452
+
453
+ # @api private
454
+ # @return [Boolean] false if status of the bucket is not healthy
455
+ def healthy?
456
+ @healthy
457
+ end
458
+
459
+ # @deprecated Use {#eviction_policy} instead
460
+ def ejection_policy
461
+ @eviction_policy
462
+ end
463
+
464
+ deprecate :ejection_policy, :eviction_policy, 2021, 1
465
+
466
+ # @deprecated Use {#eviction_policy=} instead
467
+ def ejection_policy=(val)
468
+ @eviction_policy = val
469
+ end
470
+
471
+ deprecate :ejection_policy=, :eviction_policy=, 2021, 1
472
+
473
+ # @yieldparam [BucketSettings] self
474
+ def initialize
475
+ yield self if block_given?
476
+ end
477
+ end
478
+ end
479
+ end