couchbase 3.4.2-arm64-darwin-20 → 3.4.4-arm64-darwin-20

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,21 +22,40 @@ module Couchbase
22
22
  module Query
23
23
  # Options for {QueryIndexManager#get_all_indexes}
24
24
  class GetAllIndexes < ::Couchbase::Options::Base
25
+ attr_accessor :scope_name # @return [String, nil]
26
+ attr_accessor :collection_name # @return [String, nil]
27
+
25
28
  # Creates an instance of options for {QueryIndexManager#get_all_indexes}
26
29
  #
30
+ # @param [String, nil] scope_name the name of the scope
31
+ # @param [String, nil] collection_name the name of the collection
32
+ #
27
33
  # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
28
34
  # @param [Proc, nil] retry_strategy the custom retry strategy, if set
29
35
  # @param [Hash, nil] client_context the client context data, if set
30
36
  # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
31
37
  #
32
38
  # @yieldparam [GetAllScopes] self
33
- def initialize(timeout: nil,
39
+ def initialize(scope_name: nil,
40
+ collection_name: nil,
41
+ timeout: nil,
34
42
  retry_strategy: nil,
35
43
  client_context: nil,
36
44
  parent_span: nil)
37
- super
45
+ super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
46
+ @scope_name = scope_name
47
+ @collection_name = collection_name
38
48
  yield self if block_given?
39
49
  end
50
+
51
+ # @api private
52
+ def to_backend
53
+ {
54
+ timeout: Utils::Time.extract_duration(@timeout),
55
+ scope_name: @scope_name,
56
+ collection_name: @collection_name,
57
+ }
58
+ end
40
59
  end
41
60
 
42
61
  # Options for {QueryIndexManager#create_index}
@@ -102,6 +121,7 @@ module Couchbase
102
121
  attr_accessor :ignore_if_exists # @return [Boolean]
103
122
  attr_accessor :num_replicas # @return [Integer, nil]
104
123
  attr_accessor :deferred # @return [Boolean]
124
+ attr_accessor :index_name # @return [String. nil]
105
125
  attr_accessor :scope_name # @return [String, nil]
106
126
  attr_accessor :collection_name # @return [String, nil]
107
127
 
@@ -110,6 +130,7 @@ module Couchbase
110
130
  # @param [Boolean] ignore_if_exists do not raise error if the index already exist
111
131
  # @param [Integer] num_replicas the number of replicas that this index should have
112
132
  # @param [Boolean] deferred whether the index should be created as a deferred index.
133
+ # @param [String, nil] index_name the custom name of the primary index.
113
134
  # @param [String, nil] scope_name the name of the scope
114
135
  # @param [String, nil] collection_name the name of the collection
115
136
  #
@@ -122,6 +143,7 @@ module Couchbase
122
143
  def initialize(ignore_if_exists: false,
123
144
  num_replicas: nil,
124
145
  deferred: false,
146
+ index_name: nil,
125
147
  scope_name: nil,
126
148
  collection_name: nil,
127
149
  timeout: nil,
@@ -132,6 +154,7 @@ module Couchbase
132
154
  @ignore_if_exists = ignore_if_exists
133
155
  @num_replicas = num_replicas
134
156
  @deferred = deferred
157
+ @index_name = index_name
135
158
  @scope_name = scope_name
136
159
  @collection_name = collection_name
137
160
  yield self if block_given?
@@ -144,6 +167,7 @@ module Couchbase
144
167
  ignore_if_exists: @ignore_if_exists,
145
168
  deferred: @deferred,
146
169
  num_replicas: @num_replicas,
170
+ index_name: @index_name,
147
171
  scope_name: @scope_name,
148
172
  collection_name: @collection_name,
149
173
  }
@@ -238,7 +262,12 @@ module Couchbase
238
262
 
239
263
  # Options for {QueryIndexManager#build_deferred_indexes}
240
264
  class BuildDeferredIndexes < ::Couchbase::Options::Base
265
+ attr_accessor :scope_name # @return [String, nil]
266
+ attr_accessor :collection_name # @return [String, nil]
267
+
241
268
  # Creates an instance of options for {QueryIndexManager#build_deferred_indexes}
269
+ # @param [String, nil] scope_name the name of the scope
270
+ # @param [String, nil] collection_name the name of the collection
242
271
  #
243
272
  # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
244
273
  # @param [Proc, nil] retry_strategy the custom retry strategy, if set
@@ -246,33 +275,55 @@ module Couchbase
246
275
  # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
247
276
  #
248
277
  # @yieldparam [GetAllScopes] self
249
- def initialize(timeout: nil,
278
+ def initialize(scope_name: nil,
279
+ collection_name: nil,
280
+ timeout: nil,
250
281
  retry_strategy: nil,
251
282
  client_context: nil,
252
283
  parent_span: nil)
253
- super
284
+ super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
285
+ @scope_name = scope_name
286
+ @collection_name = collection_name
254
287
  yield self if block_given?
255
288
  end
289
+
290
+ # @api private
291
+ def to_backend
292
+ {
293
+ timeout: Utils::Time.extract_duration(@timeout),
294
+ scope_name: @scope_name,
295
+ collection_name: @collection_name,
296
+ }
297
+ end
256
298
  end
257
299
 
258
300
  # Options for {QueryIndexManager#watch_indexes}
259
301
  class WatchIndexes < ::Couchbase::Options::Base
260
302
  attr_accessor :watch_primary # @return [Boolean]
303
+ attr_accessor :scope_name # @return [String, nil]
304
+ attr_accessor :collection_name # @return [String, nil]
261
305
 
262
306
  # Creates an instance of options for {QueryIndexManager#watch_indexes}
263
307
  #
264
308
  # @param [Boolean] watch_primary whether or not to watch the primary index
309
+ # @param [String, nil] scope_name the name of the scope
310
+ # @param [String, nil] collection_name the name of the collection
311
+ #
265
312
  # @param [Proc, nil] retry_strategy the custom retry strategy, if set
266
313
  # @param [Hash, nil] client_context the client context data, if set
267
314
  # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
268
315
  #
269
316
  # @yieldparam [GetAllScopes] self
270
317
  def initialize(watch_primary: false,
318
+ scope_name: nil,
319
+ collection_name: nil,
271
320
  retry_strategy: nil,
272
321
  client_context: nil,
273
322
  parent_span: nil)
274
323
  super(timeout: nil, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
275
324
  @watch_primary = watch_primary
325
+ @scope_name = scope_name
326
+ @collection_name = collection_name
276
327
  yield self if block_given?
277
328
  end
278
329
 
@@ -280,6 +331,8 @@ module Couchbase
280
331
  def to_backend
281
332
  {
282
333
  watch_primary: @watch_primary,
334
+ scope_name: @scope_name,
335
+ collection_name: @collection_name,
283
336
  }
284
337
  end
285
338
  end
@@ -343,6 +396,10 @@ module Couchbase
343
396
  #
344
397
  # @raise [ArgumentError]
345
398
  def get_all_indexes(bucket_name, options = GetAllIndexOptions.new)
399
+ unless options.scope_name.nil? && options.collection_name.nil?
400
+ warn "The attributes 'scope_name' and 'collection_name' have been deprecated. Use 'collection.query_indexes' instead"
401
+ end
402
+
346
403
  res = @backend.query_index_get_all(bucket_name, options.to_backend)
347
404
  res[:indexes].map do |idx|
348
405
  QueryIndex.new do |index|
@@ -436,10 +493,14 @@ module Couchbase
436
493
  # @param [String] bucket_name name of the bucket
437
494
  # @param [Options::Query::BuildDeferredIndexes] options
438
495
  #
439
- # @return void
496
+ # @return
440
497
  #
441
498
  # @raise [ArgumentError]
442
499
  def build_deferred_indexes(bucket_name, options = Options::Query::BuildDeferredIndexes.new)
500
+ unless options.scope_name.nil? && options.collection_name.nil?
501
+ warn "The attributes 'scope_name' and 'collection_name' have been deprecated. Use 'collection.query_indexes' instead"
502
+ end
503
+
443
504
  @backend.query_index_build_deferred(bucket_name, options.to_backend)
444
505
  end
445
506
 
@@ -453,6 +514,10 @@ module Couchbase
453
514
  # @raise [ArgumentError]
454
515
  # @raise [Error::IndexNotFound]
455
516
  def watch_indexes(bucket_name, index_names, timeout, options = Options::Query::WatchIndexes.new)
517
+ unless options.scope_name.nil? && options.collection_name.nil?
518
+ warn "The attributes 'scope_name' and 'collection_name' have been deprecated. Use 'collection.query_indexes' instead"
519
+ end
520
+
456
521
  index_names.append("#primary") if options.watch_primary
457
522
 
458
523
  interval_millis = 50
@@ -1026,6 +1026,151 @@ module Couchbase
1026
1026
  DEFAULT = LookupIn.new.freeze
1027
1027
  end
1028
1028
 
1029
+ # Options for {Collection#lookup_in_any_replica}
1030
+ class LookupInAnyReplica < Base
1031
+ attr_accessor :transcoder # @return [JsonTranscoder, #decode(String)]
1032
+
1033
+ # Creates an instance of options for {Collection#lookup_in_any_replica}
1034
+ #
1035
+ # @param [JsonTranscoder, #decode(String)] transcoder used for encoding
1036
+ #
1037
+ # @param [Integer, #in_milliseconds, nil] timeout
1038
+ # @param [Proc, nil] retry_strategy the custom retry strategy, if set
1039
+ # @param [Hash, nil] client_context the client context data, if set
1040
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
1041
+ #
1042
+ # @yieldparam [LookupIn] self
1043
+ def initialize(transcoder: JsonTranscoder.new,
1044
+ timeout: nil,
1045
+ retry_strategy: nil,
1046
+ client_context: nil,
1047
+ parent_span: nil)
1048
+ super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
1049
+ @transcoder = transcoder
1050
+ yield self if block_given?
1051
+ end
1052
+
1053
+ # @api private
1054
+ def to_backend
1055
+ {
1056
+ timeout: Utils::Time.extract_duration(@timeout),
1057
+ }
1058
+ end
1059
+
1060
+ # @api private
1061
+ # @return [Boolean]
1062
+ attr_accessor :access_deleted
1063
+
1064
+ # @api private
1065
+ DEFAULT = LookupInAnyReplica.new.freeze
1066
+ end
1067
+
1068
+ # Options for {Collection#lookup_in_all_replicas}
1069
+ class LookupInAllReplicas < Base
1070
+ attr_accessor :transcoder # @return [JsonTranscoder, #decode(String)]
1071
+
1072
+ # Creates an instance of options for {Collection#lookup_in_all_replicas}
1073
+ #
1074
+ # @param [JsonTranscoder, #decode(String)] transcoder used for encoding
1075
+ #
1076
+ # @param [Integer, #in_milliseconds, nil] timeout
1077
+ # @param [Proc, nil] retry_strategy the custom retry strategy, if set
1078
+ # @param [Hash, nil] client_context the client context data, if set
1079
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
1080
+ #
1081
+ # @yieldparam [LookupInAllReplicas] self
1082
+ def initialize(transcoder: JsonTranscoder.new,
1083
+ timeout: nil,
1084
+ retry_strategy: nil,
1085
+ client_context: nil,
1086
+ parent_span: nil)
1087
+ super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
1088
+ @transcoder = transcoder
1089
+ yield self if block_given?
1090
+ end
1091
+
1092
+ # @api private
1093
+ def to_backend
1094
+ {
1095
+ timeout: Utils::Time.extract_duration(@timeout),
1096
+ }
1097
+ end
1098
+
1099
+ # @api private
1100
+ DEFAULT = LookupInAllReplicas.new.freeze
1101
+ end
1102
+
1103
+ # Options for {Collection#scan}
1104
+ class Scan < Base
1105
+ attr_accessor :ids_only # @return [Boolean]
1106
+ attr_accessor :transcoder # @return [JsonTranscoder, #decode(String)]
1107
+ attr_accessor :mutation_state # @return [MutationState, nil]
1108
+ attr_accessor :batch_byte_limit # @return [Integer, nil]
1109
+ attr_accessor :batch_item_limit # @return [Integer, nil]
1110
+ attr_accessor :concurrency # @return [Integer, nil]
1111
+
1112
+ # Creates an instance of options for {Collection#scan}
1113
+ #
1114
+ # @param [Boolean] ids_only if set to true, the content of the documents is not included in the results
1115
+ # @param [JsonTranscoder, #decode(String)] transcoder used for decoding
1116
+ # @param [MutationState, nil] mutation_state sets the mutation tokens this scan should be consistent with
1117
+ # @param [Integer, nil] batch_byte_limit allows to limit the maximum amount of bytes that are sent from the server
1118
+ # to the client on each partition batch, defaults to 15,000
1119
+ # @param [Integer, nil] batch_item_limit allows to limit the maximum amount of items that are sent from the server
1120
+ # to the client on each partition batch, defaults to 50
1121
+ # @param [Integer, nil] concurrency specifies the maximum number of partitions that can be scanned concurrently,
1122
+ # defaults to 1
1123
+ #
1124
+ # @param [Integer, #in_milliseconds, nil] timeout
1125
+ # @param [Proc, nil] retry_strategy the custom retry strategy, if set
1126
+ # @param [Hash, nil] client_context the client context data, if set
1127
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
1128
+ #
1129
+ # @yieldparam [LookupIn] self
1130
+ def initialize(ids_only: false,
1131
+ transcoder: JsonTranscoder.new,
1132
+ mutation_state: nil,
1133
+ batch_byte_limit: nil,
1134
+ batch_item_limit: nil,
1135
+ concurrency: nil,
1136
+ timeout: nil,
1137
+ retry_strategy: nil,
1138
+ client_context: nil,
1139
+ parent_span: nil)
1140
+ super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
1141
+ @ids_only = ids_only
1142
+ @transcoder = transcoder
1143
+ @mutation_state = mutation_state
1144
+ @batch_byte_limit = batch_byte_limit
1145
+ @batch_item_limit = batch_item_limit
1146
+ @concurrency = concurrency
1147
+ yield self if block_given?
1148
+ end
1149
+
1150
+ # Sets the mutation tokens this query should be consistent with
1151
+ #
1152
+ # @note overrides consistency level set by {#scan_consistency=}
1153
+ #
1154
+ # @param [MutationState] mutation_state the mutation state containing the mutation tokens
1155
+ def consistent_with(mutation_state)
1156
+ @mutation_state = mutation_state
1157
+ end
1158
+
1159
+ # @api private
1160
+ def to_backend
1161
+ {
1162
+ timeout: Utils::Time.extract_duration(@timeout),
1163
+ ids_only: @ids_only,
1164
+ mutation_state: @mutation_state.to_a,
1165
+ batch_byte_limit: @batch_byte_limit,
1166
+ batch_item_limit: @batch_item_limit,
1167
+ concurrency: @concurrency,
1168
+ }
1169
+ end
1170
+
1171
+ DEFAULT = Scan.new.freeze
1172
+ end
1173
+
1029
1174
  # Options for {BinaryCollection#append}
1030
1175
  class Append < Base
1031
1176
  attr_accessor :cas # @return [Integer]
@@ -1849,6 +1994,7 @@ module Couchbase
1849
1994
  attr_accessor :profile # @return [Symbol]
1850
1995
  attr_accessor :flex_index # @return [Boolean]
1851
1996
  attr_accessor :preserve_expiry # @return [Boolean]
1997
+ attr_accessor :use_replica # @return [Boolean, nil]
1852
1998
  attr_accessor :scope_qualifier # @return [String]
1853
1999
  attr_accessor :transcoder # @return [JsonTranscoder, #decode(String)]
1854
2000
 
@@ -1894,6 +2040,8 @@ module Couchbase
1894
2040
  # @param [Boolean, nil] flex_index Tells the query engine to use a flex index (utilizing the search service)
1895
2041
  # @param [Boolean, nil] preserve_expiry Tells the query engine to preserve expiration values set on any documents
1896
2042
  # modified by this query.
2043
+ # @param [Boolean, nil] use_replica Specifies that the query engine should use replica nodes for KV fetches if
2044
+ # the active node is down. If not provided, the server default will be used
1897
2045
  # @param [String, nil] scope_qualifier Associate scope qualifier (also known as +query_context+) with the query.
1898
2046
  # The qualifier must be in form +{bucket_name}.{scope_name}+ or +default:{bucket_name}.{scope_name}+.
1899
2047
  # @param [JsonTranscoder] transcoder to decode rows
@@ -1925,6 +2073,7 @@ module Couchbase
1925
2073
  profile: :off,
1926
2074
  flex_index: nil,
1927
2075
  preserve_expiry: nil,
2076
+ use_replica: nil,
1928
2077
  scope_qualifier: nil,
1929
2078
  scan_consistency: :not_bounded,
1930
2079
  mutation_state: nil,
@@ -1950,6 +2099,7 @@ module Couchbase
1950
2099
  @profile = profile
1951
2100
  @flex_index = flex_index
1952
2101
  @preserve_expiry = preserve_expiry
2102
+ @use_replica = use_replica
1953
2103
  @scope_qualifier = scope_qualifier
1954
2104
  @scan_consistency = scan_consistency
1955
2105
  @mutation_state = mutation_state
@@ -2043,6 +2193,7 @@ module Couchbase
2043
2193
  readonly: @readonly,
2044
2194
  flex_index: @flex_index,
2045
2195
  preserve_expiry: @preserve_expiry,
2196
+ use_replica: @use_replica,
2046
2197
  scan_wait: Utils::Time.extract_duration(@scan_wait),
2047
2198
  scan_cap: @scan_cap,
2048
2199
  pipeline_batch: @pipeline_batch,
@@ -0,0 +1,37 @@
1
+ # Copyright 2023. 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/transcoder_flags"
16
+
17
+ module Couchbase
18
+ class RawBinaryTranscoder
19
+ # @param [String] document
20
+ # @return [Array<String, Integer>] pair of encoded document and flags
21
+ def encode(document)
22
+ raise Error::EncodingFailure, "Only binary data supported by RawBinaryTranscoder" unless document.is_a?(String)
23
+
24
+ [document, TranscoderFlags.new(format: :binary).encode]
25
+ end
26
+
27
+ # @param [String] blob string of bytes, containing encoded representation of the document
28
+ # @param [Integer] flags bit field, describing how the data encoded
29
+ # @return [String] decoded document
30
+ def decode(blob, flags)
31
+ format = TranscoderFlags.decode(flags).format
32
+ raise Error::DecodingFailure, "Unable to decode #{format} with the RawBinaryTranscoder" unless format == :binary || format.nil?
33
+
34
+ blob
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,38 @@
1
+ # Copyright 2023. 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/transcoder_flags"
16
+ require "couchbase/errors"
17
+
18
+ module Couchbase
19
+ class RawJsonTranscoder
20
+ # @param [String] document
21
+ # @return [Array<String, Integer>] pair of encoded document and flags
22
+ def encode(document)
23
+ raise Error::EncodingFailure, "Only String and binary data supported by RawJsonTranscoder" unless document.is_a?(String)
24
+
25
+ [document, TranscoderFlags.new(format: :json).encode]
26
+ end
27
+
28
+ # @param [String] blob string of bytes, containing encoded representation of the document
29
+ # @param [Integer] flags bit field, describing how the data encoded
30
+ # @return [String] decoded document
31
+ def decode(blob, flags)
32
+ format = TranscoderFlags.decode(flags).format
33
+ raise Error::DecodingFailure, "Unable to decode #{format} with the RawJsonTranscoder" unless format == :json || format.nil?
34
+
35
+ blob
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,40 @@
1
+ # Copyright 2023. 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/transcoder_flags"
16
+ require "couchbase/errors"
17
+
18
+ module Couchbase
19
+ class RawStringTranscoder
20
+ # @param [String] document
21
+ # @return [Array<String, Integer>] pair of encoded document and flags
22
+ def encode(document)
23
+ unless document.is_a?(String) && document.valid_encoding?
24
+ raise Error::EncodingFailure, "Only String data supported by RawStringTranscoder"
25
+ end
26
+
27
+ [document, TranscoderFlags.new(format: :string).encode]
28
+ end
29
+
30
+ # @param [String] blob string of bytes, containing encoded representation of the document
31
+ # @param [Integer] flags bit field, describing how the data encoded
32
+ # @return [String] decoded document
33
+ def decode(blob, flags)
34
+ format = TranscoderFlags.decode(flags).format
35
+ raise Error::DecodingFailure, "Unable to decode #{format} with the RawStringTranscoder" unless format == :string || format.nil?
36
+
37
+ blob
38
+ end
39
+ end
40
+ end
@@ -79,7 +79,7 @@ module Couchbase
79
79
  metrics.warning_count = resp[:meta][:metrics][:warning_count]
80
80
  end
81
81
  end
82
- res[:warnings] = resp[:warnings].map { |warn| Cluster::QueryWarning.new(warn[:code], warn[:message]) } if resp[:warnings]
82
+ meta.warnings = resp[:warnings].map { |warn| Cluster::QueryWarning.new(warn[:code], warn[:message]) } if resp[:warnings]
83
83
  end
84
84
  res.instance_variable_set(:@rows, resp[:rows])
85
85
  end
@@ -1225,6 +1225,11 @@ module Couchbase
1225
1225
 
1226
1226
  # @return [Array<Integer>] the positions of the term within any elements.
1227
1227
  attr_accessor :array_positions
1228
+
1229
+ # @yieldparam [SearchRowLocation] self
1230
+ def initialize
1231
+ yield self if block_given?
1232
+ end
1228
1233
  end
1229
1234
 
1230
1235
  class SearchRowLocations
@@ -0,0 +1,62 @@
1
+ # Copyright 2023. 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
+ module Couchbase
16
+ # @api private
17
+ class TranscoderFlags
18
+ FORMAT_MAP = {
19
+ reserved: 0,
20
+ private: 1,
21
+ json: 2,
22
+ binary: 3,
23
+ string: 4,
24
+ }.freeze
25
+ INV_FORMAT_MAP = FORMAT_MAP.invert.freeze
26
+
27
+ COMPRESSION_MAP = {none: 0}.freeze
28
+ INV_COMPRESSION_MAP = COMPRESSION_MAP.invert
29
+
30
+ attr_reader :format
31
+ attr_reader :compression
32
+ attr_reader :lower_bits
33
+
34
+ def initialize(format:, compression: :none, lower_bits: 0)
35
+ @format = format
36
+ @compression = compression
37
+ @lower_bits = lower_bits
38
+ end
39
+
40
+ def self.decode(flags)
41
+ return TranscoderFlags.new(format: flags) if flags.is_a?(Symbol)
42
+
43
+ common_flags = flags >> 24
44
+ lower_bits = flags & 0x00ffff
45
+
46
+ return TranscoderFlags.new(format: nil, lower_bits: lower_bits) if common_flags.zero?
47
+
48
+ compression_bits = common_flags >> 5
49
+ format_bits = common_flags & 0x0f
50
+ TranscoderFlags.new(
51
+ format: INV_FORMAT_MAP[format_bits],
52
+ compression: INV_COMPRESSION_MAP[compression_bits],
53
+ lower_bits: lower_bits
54
+ )
55
+ end
56
+
57
+ def encode
58
+ common_flags = (COMPRESSION_MAP[@compression] << 5) | FORMAT_MAP[@format]
59
+ (common_flags << 24) | @lower_bits
60
+ end
61
+ end
62
+ end
@@ -48,8 +48,21 @@ module Couchbase
48
48
  end
49
49
  end
50
50
 
51
+ # This method converts its argument to milliseconds
52
+ #
53
+ # 1. Integer values are interpreted as a number of milliseconds
54
+ # 2. If the argument is a Duration-like object and responds to #in_milliseconds,
55
+ # then use it and convert result to Integer
56
+ # 3. Otherwise invoke #to_i on the argument and interpret it as a number of milliseconds
51
57
  def extract_duration(number_or_duration)
52
- number_or_duration.respond_to?(:in_milliseconds) ? number_or_duration.public_send(:in_milliseconds) : number_or_duration
58
+ return unless number_or_duration
59
+ return number_or_duration if number_or_duration.class == Integer # rubocop:disable Style/ClassEqualityComparison avoid overrides of #is_a?, #kind_of?
60
+
61
+ if number_or_duration.respond_to?(:in_milliseconds)
62
+ number_or_duration.public_send(:in_milliseconds)
63
+ else
64
+ number_or_duration
65
+ end.to_i
53
66
  end
54
67
  end
55
68
  end
@@ -19,5 +19,5 @@ module Couchbase
19
19
  # $ ruby -rcouchbase -e 'pp Couchbase::VERSION'
20
20
  # {:sdk=>"3.4.0", :ruby_abi=>"3.1.0", :revision=>"416fe68e6029ec8a4c40611cf6e6b30d3b90d20f"}
21
21
  VERSION = {} unless defined?(VERSION) # rubocop:disable Style/MutableConstant
22
- VERSION.update(:sdk => "3.4.2".freeze)
22
+ VERSION.update(:sdk => "3.4.4".freeze)
23
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: couchbase
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.2
4
+ version: 3.4.4
5
5
  platform: arm64-darwin-20
6
6
  authors:
7
7
  - Sergey Avseyev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-12 00:00:00.000000000 Z
11
+ date: 2023-08-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Modern SDK for Couchbase Server
14
14
  email:
@@ -41,6 +41,7 @@ files:
41
41
  - lib/couchbase/diagnostics.rb
42
42
  - lib/couchbase/errors.rb
43
43
  - lib/couchbase/json_transcoder.rb
44
+ - lib/couchbase/key_value_scan.rb
44
45
  - lib/couchbase/libcouchbase.bundle
45
46
  - lib/couchbase/logger.rb
46
47
  - lib/couchbase/management.rb
@@ -56,9 +57,13 @@ files:
56
57
  - lib/couchbase/options.rb
57
58
  - lib/couchbase/query_options.rb
58
59
  - lib/couchbase/railtie.rb
60
+ - lib/couchbase/raw_binary_transcoder.rb
61
+ - lib/couchbase/raw_json_transcoder.rb
62
+ - lib/couchbase/raw_string_transcoder.rb
59
63
  - lib/couchbase/scope.rb
60
64
  - lib/couchbase/search_options.rb
61
65
  - lib/couchbase/subdoc.rb
66
+ - lib/couchbase/transcoder_flags.rb
62
67
  - lib/couchbase/utils.rb
63
68
  - lib/couchbase/utils/generic_logger_adapter.rb
64
69
  - lib/couchbase/utils/stdlib_logger_adapter.rb
@@ -73,9 +78,9 @@ metadata:
73
78
  homepage_uri: https://docs.couchbase.com/ruby-sdk/current/hello-world/start-using-sdk.html
74
79
  bug_tracker_uri: https://couchbase.com/issues/browse/RCBC
75
80
  mailing_list_uri: https://forums.couchbase.com/c/ruby-sdk
76
- source_code_uri: https://github.com/couchbase/couchbase-ruby-client/tree/3.4.2
77
- changelog_uri: https://github.com/couchbase/couchbase-ruby-client/releases/tag/3.4.2
78
- documentation_uri: https://docs.couchbase.com/sdk-api/couchbase-ruby-client-3.4.2/index.html
81
+ source_code_uri: https://github.com/couchbase/couchbase-ruby-client/tree/3.4.4
82
+ changelog_uri: https://github.com/couchbase/couchbase-ruby-client/releases/tag/3.4.4
83
+ documentation_uri: https://docs.couchbase.com/sdk-api/couchbase-ruby-client-3.4.4/index.html
79
84
  github_repo: ssh://github.com/couchbase/couchbase-ruby-client
80
85
  rubygems_mfa_required: 'true'
81
86
  post_install_message: