couchbase 3.5.0-x86_64-linux-musl
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/3.1/libcouchbase.so +0 -0
- data/lib/couchbase/3.2/libcouchbase.so +0 -0
- data/lib/couchbase/3.3/libcouchbase.so +0 -0
- data/lib/couchbase/analytics_options.rb +107 -0
- data/lib/couchbase/authenticator.rb +64 -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 +460 -0
- data/lib/couchbase/cluster_registry.rb +49 -0
- data/lib/couchbase/collection.rb +705 -0
- data/lib/couchbase/collection_options.rb +399 -0
- data/lib/couchbase/config_profiles.rb +55 -0
- data/lib/couchbase/configuration.rb +56 -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 +376 -0
- data/lib/couchbase/json_transcoder.rb +39 -0
- data/lib/couchbase/key_value_scan.rb +117 -0
- data/lib/couchbase/libcouchbase.rb +6 -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 +443 -0
- data/lib/couchbase/management/collection_manager.rb +470 -0
- data/lib/couchbase/management/collection_query_index_manager.rb +222 -0
- data/lib/couchbase/management/query_index_manager.rb +617 -0
- data/lib/couchbase/management/scope_search_index_manager.rb +198 -0
- data/lib/couchbase/management/search_index_manager.rb +424 -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 +29 -0
- data/lib/couchbase/mutation_state.rb +63 -0
- data/lib/couchbase/options.rb +2837 -0
- data/lib/couchbase/protostellar/binary_collection.rb +55 -0
- data/lib/couchbase/protostellar/bucket.rb +51 -0
- data/lib/couchbase/protostellar/client.rb +99 -0
- data/lib/couchbase/protostellar/cluster.rb +163 -0
- data/lib/couchbase/protostellar/collection.rb +152 -0
- data/lib/couchbase/protostellar/connect_options.rb +63 -0
- data/lib/couchbase/protostellar/error_handling.rb +203 -0
- data/lib/couchbase/protostellar/generated/admin/bucket/v1/bucket_pb.rb +61 -0
- data/lib/couchbase/protostellar/generated/admin/bucket/v1/bucket_services_pb.rb +35 -0
- data/lib/couchbase/protostellar/generated/admin/collection/v1/collection_pb.rb +57 -0
- data/lib/couchbase/protostellar/generated/admin/collection/v1/collection_services_pb.rb +36 -0
- data/lib/couchbase/protostellar/generated/admin/query/v1/query_pb.rb +61 -0
- data/lib/couchbase/protostellar/generated/admin/query/v1/query_services_pb.rb +37 -0
- data/lib/couchbase/protostellar/generated/admin/search/v1/search_pb.rb +72 -0
- data/lib/couchbase/protostellar/generated/admin/search/v1/search_services_pb.rb +44 -0
- data/lib/couchbase/protostellar/generated/analytics/v1/analytics_pb.rb +52 -0
- data/lib/couchbase/protostellar/generated/analytics/v1/analytics_services_pb.rb +30 -0
- data/lib/couchbase/protostellar/generated/internal/hooks/v1/hooks_pb.rb +70 -0
- data/lib/couchbase/protostellar/generated/internal/hooks/v1/hooks_services_pb.rb +36 -0
- data/lib/couchbase/protostellar/generated/kv/v1/kv_pb.rb +97 -0
- data/lib/couchbase/protostellar/generated/kv/v1/kv_services_pb.rb +46 -0
- data/lib/couchbase/protostellar/generated/query/v1/query_pb.rb +57 -0
- data/lib/couchbase/protostellar/generated/query/v1/query_services_pb.rb +30 -0
- data/lib/couchbase/protostellar/generated/routing/v1/routing_pb.rb +52 -0
- data/lib/couchbase/protostellar/generated/routing/v1/routing_services_pb.rb +30 -0
- data/lib/couchbase/protostellar/generated/search/v1/search_pb.rb +99 -0
- data/lib/couchbase/protostellar/generated/search/v1/search_services_pb.rb +30 -0
- data/lib/couchbase/protostellar/generated/transactions/v1/transactions_pb.rb +57 -0
- data/lib/couchbase/protostellar/generated/transactions/v1/transactions_services_pb.rb +36 -0
- data/lib/couchbase/protostellar/generated/view/v1/view_pb.rb +51 -0
- data/lib/couchbase/protostellar/generated/view/v1/view_services_pb.rb +30 -0
- data/lib/couchbase/protostellar/generated.rb +9 -0
- data/lib/couchbase/protostellar/management/bucket_manager.rb +67 -0
- data/lib/couchbase/protostellar/management/collection_manager.rb +94 -0
- data/lib/couchbase/protostellar/management/collection_query_index_manager.rb +124 -0
- data/lib/couchbase/protostellar/management/query_index_manager.rb +112 -0
- data/lib/couchbase/protostellar/management.rb +24 -0
- data/lib/couchbase/protostellar/request.rb +78 -0
- data/lib/couchbase/protostellar/request_behaviour.rb +42 -0
- data/lib/couchbase/protostellar/request_generator/admin/bucket.rb +124 -0
- data/lib/couchbase/protostellar/request_generator/admin/collection.rb +94 -0
- data/lib/couchbase/protostellar/request_generator/admin/query.rb +130 -0
- data/lib/couchbase/protostellar/request_generator/admin.rb +24 -0
- data/lib/couchbase/protostellar/request_generator/kv.rb +474 -0
- data/lib/couchbase/protostellar/request_generator/query.rb +133 -0
- data/lib/couchbase/protostellar/request_generator/search.rb +387 -0
- data/lib/couchbase/protostellar/request_generator.rb +26 -0
- data/lib/couchbase/protostellar/response_converter/admin/bucket.rb +55 -0
- data/lib/couchbase/protostellar/response_converter/admin/collection.rb +42 -0
- data/lib/couchbase/protostellar/response_converter/admin/query.rb +59 -0
- data/lib/couchbase/protostellar/response_converter/admin.rb +24 -0
- data/lib/couchbase/protostellar/response_converter/kv.rb +151 -0
- data/lib/couchbase/protostellar/response_converter/query.rb +84 -0
- data/lib/couchbase/protostellar/response_converter/search.rb +136 -0
- data/lib/couchbase/protostellar/response_converter.rb +26 -0
- data/lib/couchbase/protostellar/retry/action.rb +38 -0
- data/lib/couchbase/protostellar/retry/orchestrator.rb +60 -0
- data/lib/couchbase/protostellar/retry/reason.rb +67 -0
- data/lib/couchbase/protostellar/retry/strategies/best_effort.rb +49 -0
- data/lib/couchbase/protostellar/retry/strategies.rb +26 -0
- data/lib/couchbase/protostellar/retry.rb +28 -0
- data/lib/couchbase/protostellar/scope.rb +57 -0
- data/lib/couchbase/protostellar/timeout_defaults.rb +30 -0
- data/lib/couchbase/protostellar/timeouts.rb +83 -0
- data/lib/couchbase/protostellar.rb +29 -0
- data/lib/couchbase/query_options.rb +120 -0
- data/lib/couchbase/railtie.rb +45 -0
- data/lib/couchbase/raw_binary_transcoder.rb +37 -0
- data/lib/couchbase/raw_json_transcoder.rb +38 -0
- data/lib/couchbase/raw_string_transcoder.rb +40 -0
- data/lib/couchbase/scope.rb +256 -0
- data/lib/couchbase/search_options.rb +1622 -0
- data/lib/couchbase/subdoc.rb +290 -0
- data/lib/couchbase/transcoder_flags.rb +62 -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 +69 -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 +28 -0
- data/lib/rails/generators/couchbase/config/config_generator.rb +27 -0
- metadata +190 -0
@@ -0,0 +1,443 @@
|
|
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 Bucket
|
24
|
+
# Options for {BucketManager#create_bucket}
|
25
|
+
class CreateBucket < ::Couchbase::Options::Base
|
26
|
+
# Creates an instance of options for {BucketManager#create_bucket}
|
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 [CreateBucket] 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 {BucketManager#update_bucket}
|
44
|
+
class UpdateBucket < ::Couchbase::Options::Base
|
45
|
+
# Creates an instance of options for {BucketManager#update_bucket}
|
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 [UpdateBucket] 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 {BucketManager#drop_bucket}
|
63
|
+
class DropBucket < ::Couchbase::Options::Base
|
64
|
+
# Creates an instance of options for {BucketManager#drop_bucket}
|
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 [DropBucket] 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 {BucketManager#get_bucket}
|
82
|
+
class GetBucket < ::Couchbase::Options::Base
|
83
|
+
# Creates an instance of options for {BucketManager#get_bucket}
|
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 [GetBucket] 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 {BucketManager#get_all_buckets}
|
101
|
+
class GetAllBuckets < ::Couchbase::Options::Base
|
102
|
+
# Creates an instance of options for {BucketManager#get_all_buckets}
|
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 [GetAllBuckets] 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
|
+
# Options for {BucketManager#flush_bucket}
|
120
|
+
class FlushBucket < ::Couchbase::Options::Base
|
121
|
+
# Creates an instance of options for {BucketManager#flush_bucket}
|
122
|
+
#
|
123
|
+
# @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
|
124
|
+
# @param [Proc, nil] retry_strategy the custom retry strategy, if set
|
125
|
+
# @param [Hash, nil] client_context the client context data, if set
|
126
|
+
# @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
|
127
|
+
#
|
128
|
+
# @yieldparam [FlushBucket] self
|
129
|
+
def initialize(timeout: nil,
|
130
|
+
retry_strategy: nil,
|
131
|
+
client_context: nil,
|
132
|
+
parent_span: nil)
|
133
|
+
super
|
134
|
+
yield self if block_given?
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
# rubocop:disable Naming/MethodName constructor shortcuts
|
139
|
+
module_function
|
140
|
+
|
141
|
+
# Construct {CreateBucket} options for {BucketManager#create_bucket}
|
142
|
+
#
|
143
|
+
# @return [CreateBucket]
|
144
|
+
def CreateBucket(**args)
|
145
|
+
CreateBucket.new(**args)
|
146
|
+
end
|
147
|
+
|
148
|
+
# Construct {UpdateBucket} options for {BucketManager#update_bucket}
|
149
|
+
#
|
150
|
+
# @return [UpdateBucket]
|
151
|
+
def UpdateBucket(**args)
|
152
|
+
UpdateBucket.new(**args)
|
153
|
+
end
|
154
|
+
|
155
|
+
# Construct {DropBucket} options for {BucketManager#drop_bucket}
|
156
|
+
#
|
157
|
+
# @return [DropBucket]
|
158
|
+
def DropBucket(**args)
|
159
|
+
DropBucket.new(**args)
|
160
|
+
end
|
161
|
+
|
162
|
+
# Construct {GetBucket} options for {BucketManager#get_bucket}
|
163
|
+
#
|
164
|
+
# @return [GetBucket]
|
165
|
+
def GetBucket(**args)
|
166
|
+
GetBucket.new(**args)
|
167
|
+
end
|
168
|
+
|
169
|
+
# Construct {GetAllBuckets} options for {BucketManager#get_all_buckets}
|
170
|
+
#
|
171
|
+
# @return [GetAllBuckets]
|
172
|
+
def GetAllBuckets(**args)
|
173
|
+
GetAllBuckets.new(**args)
|
174
|
+
end
|
175
|
+
|
176
|
+
# Construct {FlushBucket} options for {BucketManager#flush_bucket}
|
177
|
+
#
|
178
|
+
# @return [FlushBucket]
|
179
|
+
def FlushBucket(**args)
|
180
|
+
FlushBucket.new(**args)
|
181
|
+
end
|
182
|
+
|
183
|
+
# rubocop:enable Naming/MethodName
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
class BucketManager
|
188
|
+
alias inspect to_s
|
189
|
+
|
190
|
+
# @param [Couchbase::Backend] backend
|
191
|
+
def initialize(backend)
|
192
|
+
@backend = backend
|
193
|
+
end
|
194
|
+
|
195
|
+
# Creates new bucket
|
196
|
+
#
|
197
|
+
# @param [BucketSettings] settings bucket settings
|
198
|
+
# @param [Options::Bucket::CreateBucket] options
|
199
|
+
#
|
200
|
+
# @return void
|
201
|
+
#
|
202
|
+
# @raise [ArgumentError]
|
203
|
+
# @raise [Error::BucketExists]
|
204
|
+
def create_bucket(settings, options = Options::Bucket::CreateBucket.new)
|
205
|
+
@backend.bucket_create(
|
206
|
+
{
|
207
|
+
|
208
|
+
name: settings.name,
|
209
|
+
flush_enabled: settings.flush_enabled,
|
210
|
+
ram_quota_mb: settings.ram_quota_mb,
|
211
|
+
num_replicas: settings.num_replicas,
|
212
|
+
replica_indexes: settings.replica_indexes,
|
213
|
+
bucket_type: settings.bucket_type,
|
214
|
+
eviction_policy: settings.eviction_policy,
|
215
|
+
max_expiry: settings.max_expiry,
|
216
|
+
compression_mode: settings.compression_mode,
|
217
|
+
minimum_durability_level: settings.minimum_durability_level,
|
218
|
+
conflict_resolution_type: settings.conflict_resolution_type,
|
219
|
+
storage_backend: settings.storage_backend,
|
220
|
+
history_retention_collection_default: settings.history_retention_collection_default,
|
221
|
+
history_retention_duration: settings.history_retention_duration,
|
222
|
+
history_retention_bytes: settings.history_retention_bytes,
|
223
|
+
}, options.to_backend
|
224
|
+
)
|
225
|
+
end
|
226
|
+
|
227
|
+
# Updates the bucket settings
|
228
|
+
#
|
229
|
+
# @param [BucketSettings] settings bucket settings
|
230
|
+
# @param [Options::Bucket::UpdateBucket] options
|
231
|
+
#
|
232
|
+
# @return void
|
233
|
+
#
|
234
|
+
# @raise [ArgumentError]
|
235
|
+
# @raise [Error::BucketNotFound]
|
236
|
+
def update_bucket(settings, options = Options::Bucket::UpdateBucket.new)
|
237
|
+
@backend.bucket_update(
|
238
|
+
{
|
239
|
+
name: settings.name,
|
240
|
+
flush_enabled: settings.flush_enabled,
|
241
|
+
ram_quota_mb: settings.ram_quota_mb,
|
242
|
+
num_replicas: settings.num_replicas,
|
243
|
+
replica_indexes: settings.replica_indexes,
|
244
|
+
bucket_type: settings.bucket_type,
|
245
|
+
eviction_policy: settings.eviction_policy,
|
246
|
+
max_expiry: settings.max_expiry,
|
247
|
+
compression_mode: settings.compression_mode,
|
248
|
+
minimum_durability_level: settings.minimum_durability_level,
|
249
|
+
storage_backend: settings.storage_backend,
|
250
|
+
history_retention_collection_default: settings.history_retention_collection_default,
|
251
|
+
history_retention_bytes: settings.history_retention_bytes,
|
252
|
+
history_retention_duration: settings.history_retention_duration,
|
253
|
+
}, options.to_backend
|
254
|
+
)
|
255
|
+
end
|
256
|
+
|
257
|
+
# Removes a bucket
|
258
|
+
#
|
259
|
+
# @param [String] bucket_name name of the bucket
|
260
|
+
# @param [Options::Bucket::DropBucket] options
|
261
|
+
#
|
262
|
+
# @return void
|
263
|
+
#
|
264
|
+
# @raise [ArgumentError]
|
265
|
+
# @raise [Error::BucketNotFound]
|
266
|
+
def drop_bucket(bucket_name, options = Options::Bucket::DropBucket.new)
|
267
|
+
@backend.bucket_drop(bucket_name, options.to_backend)
|
268
|
+
end
|
269
|
+
|
270
|
+
# Fetch settings of the bucket
|
271
|
+
#
|
272
|
+
# @param [String] bucket_name name of the bucket
|
273
|
+
# @param [Options::Bucket::GetBucket] options
|
274
|
+
#
|
275
|
+
# @return [BucketSettings]
|
276
|
+
#
|
277
|
+
# @raise [ArgumentError]
|
278
|
+
# @raise [Error::BucketNotFound]
|
279
|
+
def get_bucket(bucket_name, options = Options::Bucket::GetBucket.new)
|
280
|
+
extract_bucket_settings(@backend.bucket_get(bucket_name, options.to_backend))
|
281
|
+
end
|
282
|
+
|
283
|
+
# Get settings for all buckets
|
284
|
+
#
|
285
|
+
# @param [Options::Bucket::GetAllBuckets] options
|
286
|
+
# @return [Array<BucketSettings>]
|
287
|
+
def get_all_buckets(options = Options::Bucket::GetAllBuckets.new)
|
288
|
+
@backend.bucket_get_all(options.to_backend)
|
289
|
+
.map { |entry| extract_bucket_settings(entry) }
|
290
|
+
end
|
291
|
+
|
292
|
+
# @param [String] bucket_name name of the bucket
|
293
|
+
# @param [Options::Bucket::FlushBucket] options
|
294
|
+
#
|
295
|
+
# @return void
|
296
|
+
#
|
297
|
+
# @raise [ArgumentError]
|
298
|
+
# @raise [Error::BucketNotFound]
|
299
|
+
# @raise [Error::BucketNotFlushable]
|
300
|
+
def flush_bucket(bucket_name, options = Options::Bucket::FlushBucket.new)
|
301
|
+
@backend.bucket_flush(bucket_name, options.to_backend)
|
302
|
+
end
|
303
|
+
|
304
|
+
# @api private
|
305
|
+
# TODO: deprecate after 3.2
|
306
|
+
CreateBucketOptions = ::Couchbase::Management::Options::Bucket::CreateBucket
|
307
|
+
|
308
|
+
# @api private
|
309
|
+
# TODO: deprecate after 3.2
|
310
|
+
UpdateBucketOptions = ::Couchbase::Management::Options::Bucket::UpdateBucket
|
311
|
+
|
312
|
+
# @api private
|
313
|
+
# TODO: deprecate after 3.2
|
314
|
+
DropBucketOptions = ::Couchbase::Management::Options::Bucket::DropBucket
|
315
|
+
|
316
|
+
# @api private
|
317
|
+
# TODO: deprecate after 3.2
|
318
|
+
GetBucketOptions = ::Couchbase::Management::Options::Bucket::GetBucket
|
319
|
+
|
320
|
+
# @api private
|
321
|
+
# TODO: deprecate after 3.2
|
322
|
+
GetAllBucketsOptions = ::Couchbase::Management::Options::Bucket::GetAllBuckets
|
323
|
+
|
324
|
+
# @api private
|
325
|
+
# TODO: deprecate after 3.2
|
326
|
+
FlushBucketOptions = ::Couchbase::Management::Options::Bucket::FlushBucket
|
327
|
+
|
328
|
+
private
|
329
|
+
|
330
|
+
def extract_bucket_settings(entry)
|
331
|
+
BucketSettings.new do |bucket|
|
332
|
+
bucket.name = entry[:name]
|
333
|
+
bucket.flush_enabled = entry[:flush_enabled]
|
334
|
+
bucket.ram_quota_mb = entry[:ram_quota_mb]
|
335
|
+
bucket.num_replicas = entry[:num_replicas]
|
336
|
+
bucket.replica_indexes = entry[:replica_indexes]
|
337
|
+
bucket.bucket_type = entry[:bucket_type]
|
338
|
+
bucket.max_expiry = entry[:max_expiry]
|
339
|
+
bucket.eviction_policy = entry[:eviction_policy]
|
340
|
+
bucket.minimum_durability_level = entry[:minimum_durability_level]
|
341
|
+
bucket.compression_mode = entry[:compression_mode]
|
342
|
+
bucket.instance_variable_set(:@healthy, entry[:nodes].all? { |node| node[:status] == "healthy" })
|
343
|
+
bucket.history_retention_collection_default = entry[:history_retention_collection_default]
|
344
|
+
bucket.history_retention_bytes = entry[:history_retention_bytes]
|
345
|
+
bucket.history_retention_duration = entry[:history_retention_duration]
|
346
|
+
end
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
class BucketSettings
|
351
|
+
extend Gem::Deprecate
|
352
|
+
|
353
|
+
# @return [String] name of the bucket
|
354
|
+
attr_accessor :name
|
355
|
+
|
356
|
+
# @return [Boolean] whether or not flush should be enabled on the bucket. Defaults to false.
|
357
|
+
attr_accessor :flush_enabled
|
358
|
+
|
359
|
+
# @return [Integer] RAM quota in megabytes for the bucket
|
360
|
+
attr_accessor :ram_quota_mb
|
361
|
+
|
362
|
+
# @return [Integer] number of replicas for documents
|
363
|
+
attr_accessor :num_replicas
|
364
|
+
|
365
|
+
# @return [Boolean] whether replica indexes should be enabled for the bucket
|
366
|
+
attr_accessor :replica_indexes
|
367
|
+
|
368
|
+
# @return [:couchbase, :memcached, :ephemeral] the type of the bucket. Defaults to +:couchbase+
|
369
|
+
attr_accessor :bucket_type
|
370
|
+
|
371
|
+
# @return [nil, :couchstore, :magma] the type of the storage backend of the bucket
|
372
|
+
attr_accessor :storage_backend
|
373
|
+
|
374
|
+
# Eviction policy to use
|
375
|
+
#
|
376
|
+
# :full:: During ejection, only the value will be ejected (key and metadata will remain in memory). Value Ejection
|
377
|
+
# needs more system memory, but provides better performance than Full Ejection. This value is only valid for
|
378
|
+
# buckets of type +:couchbase+.
|
379
|
+
#
|
380
|
+
# :value_only:: During ejection, everything (including key, metadata, and value) will be ejected. Full Ejection
|
381
|
+
# reduces the memory overhead requirement, at the cost of performance. This value is only valid for
|
382
|
+
# buckets of type +:couchbase+.
|
383
|
+
#
|
384
|
+
# :no_eviction:: Couchbase Server keeps all data until explicitly deleted, but will reject any new data if you
|
385
|
+
# reach the quota (dedicated memory) you set for your bucket. This value is only valid for buckets
|
386
|
+
# of type +:ephemeral+.
|
387
|
+
#
|
388
|
+
# :not_recently_used:: When the memory quota is reached, Couchbase Server ejects data that has not been used
|
389
|
+
# recently. This value is only valid for buckets of type +:ephemeral+.
|
390
|
+
#
|
391
|
+
# @return [:full, :value_only, :no_eviction, :not_recently_used] the eviction policy to use
|
392
|
+
attr_accessor :eviction_policy
|
393
|
+
|
394
|
+
# @return [Integer] value of TTL (expiration) in seconds for new documents created without expiration
|
395
|
+
attr_accessor :max_expiry
|
396
|
+
|
397
|
+
# @return [:off, :passive, :active] the compression mode to use
|
398
|
+
attr_accessor :compression_mode
|
399
|
+
|
400
|
+
# @return [:timestamp, :sequence_number, :custom] conflict resolution policy
|
401
|
+
attr_accessor :conflict_resolution_type
|
402
|
+
|
403
|
+
# @return [nil, :none, :majority, :majority_and_persist_to_active, :persist_to_majority] the minimum durability level
|
404
|
+
attr_accessor :minimum_durability_level
|
405
|
+
|
406
|
+
# @return [Boolean, nil] whether to enable history retention on collections by default
|
407
|
+
attr_accessor :history_retention_collection_default
|
408
|
+
|
409
|
+
# @return [Integer, nil] the maximum size, in bytes, of the change history that is written to disk for all
|
410
|
+
# collections in this bucket
|
411
|
+
attr_accessor :history_retention_bytes
|
412
|
+
|
413
|
+
# @return [Integer, nil] the maximum duration, in seconds, to be covered by the change history that is written to disk for all
|
414
|
+
# collections in this bucket
|
415
|
+
attr_accessor :history_retention_duration
|
416
|
+
|
417
|
+
# @api private
|
418
|
+
# @return [Boolean] false if status of the bucket is not healthy
|
419
|
+
def healthy?
|
420
|
+
@healthy
|
421
|
+
end
|
422
|
+
|
423
|
+
# @deprecated Use {#eviction_policy} instead
|
424
|
+
def ejection_policy
|
425
|
+
@eviction_policy
|
426
|
+
end
|
427
|
+
|
428
|
+
deprecate :ejection_policy, :eviction_policy, 2021, 1
|
429
|
+
|
430
|
+
# @deprecated Use {#eviction_policy=} instead
|
431
|
+
def ejection_policy=(val)
|
432
|
+
@eviction_policy = val
|
433
|
+
end
|
434
|
+
|
435
|
+
deprecate :ejection_policy=, :eviction_policy=, 2021, 1
|
436
|
+
|
437
|
+
# @yieldparam [BucketSettings] self
|
438
|
+
def initialize
|
439
|
+
yield self if block_given?
|
440
|
+
end
|
441
|
+
end
|
442
|
+
end
|
443
|
+
end
|