couchbase 3.4.0-arm64-darwin-20 → 3.4.1-arm64-darwin-20

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8a2277769a3018bb5da68ff42d71fd07a5c58bf5ddf909a44df354b1de15e3b8
4
- data.tar.gz: cdbd1ea416416a893e98d8f407e7758bbad151d7f74ba5ff63e7cf43ddc27fe0
3
+ metadata.gz: 0c66775f9944c58be71025321c4cd11d33068f47e723ebc3f1116172d4d1b0c2
4
+ data.tar.gz: e8cf7b5a11ac1ca879c34d89f1bc063e67e8cfd9ed8de5a435316aea9e488a74
5
5
  SHA512:
6
- metadata.gz: 3180001d391d32cbe4fd6a2ccb0c11c6f716e1a89ee52995d7deba670e1f7da7607a1b25199c499a7950fae2cb96cb9a278ae0884b182bf45f67310d92ce29ec
7
- data.tar.gz: 12411839477ef27153db8de7a97e1fb81cb88259e5e0a9964b2ea510b65c47110eaa20f44d07013c0353f74ec258f385114eefcc1a6d6b33a13c688d067caaab
6
+ metadata.gz: 49a1c6a75d971fb8a79128dfea4212425b8f5c9cb1304c12e34c23dd8587b957826146829ecb031afaabce5b82f0a79e14f9127ffa02e5be5433dde469d662d4
7
+ data.tar.gz: 491c19def9f8fbc4e124064150766c3c7be643d8f628d68eea9f4b702586ef6fc61e87820e3418635b245554f28078e9c455b2b472270e7eb415f617ce0e4157
data/README.md CHANGED
@@ -23,7 +23,7 @@ The library has been tested with MRI 3.0, 3.1 and 3.2. Supported platforms are L
23
23
  Add this line to your application's Gemfile:
24
24
 
25
25
  ```ruby
26
- gem "couchbase", "3.4.0"
26
+ gem "couchbase", "3.4.1"
27
27
  ```
28
28
 
29
29
  And then execute:
@@ -38,7 +38,7 @@ module Couchbase
38
38
  # collection.get("mydoc", Options::Get(transcoder: nil)).content #=> "foobar"
39
39
  #
40
40
  # @return [Collection::MutationResult]
41
- def append(id, content, options = Options::Append.new)
41
+ def append(id, content, options = Options::Append::DEFAULT)
42
42
  resp = @backend.document_append(@collection.bucket_name, @collection.scope_name, @collection.name,
43
43
  id, content, options.to_backend)
44
44
  Collection::MutationResult.new do |res|
@@ -59,7 +59,7 @@ module Couchbase
59
59
  # collection.get("mydoc", Options::Get(transcoder: nil)).content #=> "barfoo"
60
60
  #
61
61
  # @return [Collection::MutationResult]
62
- def prepend(id, content, options = Options::Prepend.new)
62
+ def prepend(id, content, options = Options::Prepend::DEFAULT)
63
63
  resp = @backend.document_prepend(@collection.bucket_name, @collection.scope_name, @collection.name,
64
64
  id, content, options.to_backend)
65
65
  Collection::MutationResult.new do |res|
@@ -80,7 +80,7 @@ module Couchbase
80
80
  # res.content #=> 10
81
81
  #
82
82
  # @return [CounterResult]
83
- def increment(id, options = Options::Increment.new)
83
+ def increment(id, options = Options::Increment::DEFAULT)
84
84
  resp = @backend.document_increment(@collection.bucket_name, @collection.scope_name, @collection.name, id,
85
85
  options.to_backend)
86
86
  CounterResult.new do |res|
@@ -102,7 +102,7 @@ module Couchbase
102
102
  # res.value #=> 98
103
103
  #
104
104
  # @return [CounterResult]
105
- def decrement(id, options = Options::Decrement.new)
105
+ def decrement(id, options = Options::Decrement::DEFAULT)
106
106
  resp = @backend.document_decrement(@collection.bucket_name, @collection.scope_name, @collection.name, id,
107
107
  options.to_backend)
108
108
  CounterResult.new do |res|
@@ -43,6 +43,11 @@ module Couchbase
43
43
  BinaryCollection.new(self)
44
44
  end
45
45
 
46
+ # @return [Management::CollectionQueryIndexManager]
47
+ def query_indexes
48
+ Management::CollectionQueryIndexManager.new(@backend, @bucket_name, @scope_name, @name)
49
+ end
50
+
46
51
  # Fetches the full document from the collection
47
52
  #
48
53
  # @param [String] id the document id which is used to uniquely identify it
@@ -21,6 +21,11 @@ module Couchbase
21
21
  # @return [Hash] attributes associated with the error
22
22
  attr_reader :context
23
23
 
24
+ def initialize(msg = nil, context = nil)
25
+ @context = context unless context.nil?
26
+ super(msg)
27
+ end
28
+
24
29
  def to_s
25
30
  defined?(@context) ? "#{super}, context=#{JSON.generate(@context)}" : super
26
31
  end
@@ -30,6 +35,11 @@ module Couchbase
30
35
  # @return [Hash] attributes associated with the error
31
36
  attr_reader :context
32
37
 
38
+ def initialize(msg = nil, context = nil)
39
+ @context = context unless context.nil?
40
+ super(msg)
41
+ end
42
+
33
43
  def to_s
34
44
  defined?(@context) ? "#{super}, context=#{JSON.generate(@context)}" : super
35
45
  end
Binary file
@@ -0,0 +1,183 @@
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/management/query_index_manager"
16
+ require "couchbase/utils/time"
17
+
18
+ module Couchbase
19
+ module Management
20
+ class CollectionQueryIndexManager
21
+ alias inspect to_s
22
+
23
+ # @param [Couchbase::Backend] backend
24
+ # @param [String] bucket_name name of the bucket
25
+ # @param [String] scope_name name of the scope
26
+ # @param [String] collection_name name of the collection
27
+ def initialize(backend, bucket_name, scope_name, collection_name)
28
+ @backend = backend
29
+ @bucket_name = bucket_name
30
+ @scope_name = scope_name
31
+ @collection_name = collection_name
32
+ end
33
+
34
+ # Fetches all indexes from the server
35
+ #
36
+ # @param [Options::Query::GetAllIndexes] options
37
+ #
38
+ # @return [Array<QueryIndex>]
39
+ #
40
+ # @raise [ArgumentError]
41
+ def get_all_indexes(options = Options::Query::GetAllIndexes.new)
42
+ res = @backend.collection_query_index_get_all(@bucket_name, @scope_name, @collection_name, options.to_backend)
43
+ res[:indexes].map do |idx|
44
+ QueryIndex.new do |index|
45
+ index.name = idx[:name]
46
+ index.is_primary = idx[:is_primary]
47
+ index.type = idx[:type]
48
+ index.state = idx[:state]
49
+ index.bucket = idx[:bucket_name]
50
+ index.scope = idx[:scope_name]
51
+ index.collection = idx[:collection_name]
52
+ index.index_key = idx[:index_key]
53
+ index.condition = idx[:condition]
54
+ index.partition = idx[:partition]
55
+ end
56
+ end
57
+ end
58
+
59
+ # Creates a new index
60
+ #
61
+ # @param [String] index_name name of the index
62
+ # @param [Array<String>] fields the lists of fields to create th index over
63
+ # @param [Options::Query::CreateIndex] options
64
+ #
65
+ # @return void
66
+ #
67
+ # @raise [ArgumentError]
68
+ # @raise [Error::IndexExists]
69
+ def create_index(index_name, fields, options = Options::Query::CreateIndex.new)
70
+ unless options.scope_name.nil?
71
+ raise ArgumentError, "Scope name cannot be set in the options when using the Query Index manager at the collection level"
72
+ end
73
+
74
+ unless options.collection_name.nil?
75
+ raise ArgumentError, "Collection name cannot be set in the options when using the Query Index manager at the collection level"
76
+ end
77
+
78
+ @backend.collection_query_index_create(@bucket_name, @scope_name, @collection_name, index_name, fields, options.to_backend)
79
+ end
80
+
81
+ # Creates new primary index
82
+ #
83
+ # @param [Options::Query::CreatePrimaryIndex] options
84
+ #
85
+ # @return void
86
+ #
87
+ # @raise [ArgumentError]
88
+ # @raise [Error::IndexExists]
89
+ def create_primary_index(options = Options::Query::CreatePrimaryIndex.new)
90
+ unless options.scope_name.nil?
91
+ raise ArgumentError, "Scope name cannot be set in the options when using the Query Index manager at the collection level"
92
+ end
93
+
94
+ unless options.collection_name.nil?
95
+ raise ArgumentError, "Collection name cannot be set in the options when using the Query Index manager at the collection level"
96
+ end
97
+
98
+ @backend.collection_query_index_create_primary(@bucket_name, @scope_name, @collection_name, options.to_backend)
99
+ end
100
+
101
+ # Drops the index
102
+ #
103
+ # @param [String] index_name name of the index
104
+ # @param [Options::Query::DropIndex] options
105
+ #
106
+ # @return void
107
+ #
108
+ # @raise [ArgumentError]
109
+ # @raise [Error::IndexNotFound]
110
+ def drop_index(index_name, options = Options::Query::DropIndex.new)
111
+ unless options.scope_name.nil?
112
+ raise ArgumentError, "Scope name cannot be set in the options when using the Query Index manager at the collection level"
113
+ end
114
+
115
+ unless options.collection_name.nil?
116
+ raise ArgumentError, "Collection name cannot be set in the options when using the Query Index manager at the collection level"
117
+ end
118
+
119
+ @backend.collection_query_index_drop(@bucket_name, @scope_name, @collection_name, index_name, options.to_backend)
120
+ end
121
+
122
+ # Drops the primary index
123
+ #
124
+ # @param [Options::Query::DropPrimaryIndex] options
125
+ #
126
+ # @return void
127
+ #
128
+ # @raise [ArgumentError]
129
+ # @raise [Error::IndexNotFound]
130
+ def drop_primary_index(options = Options::Query::DropPrimaryIndex.new)
131
+ unless options.scope_name.nil?
132
+ raise ArgumentError, "Scope name cannot be set in the options when using the Query Index manager at the collection level"
133
+ end
134
+
135
+ unless options.collection_name.nil?
136
+ raise ArgumentError, "Collection name cannot be set in the options when using the Query Index manager at the collection level"
137
+ end
138
+
139
+ @backend.collection_query_index_drop_primary(@bucket_name, @scope_name, @collection_name, options.to_backend)
140
+ end
141
+
142
+ # Build all indexes which are currently in deferred state
143
+ #
144
+ # @param [Options::Query::BuildDeferredIndexes] options
145
+ #
146
+ # @return void
147
+ #
148
+ # @raise [ArgumentError]
149
+ def build_deferred_indexes(options = Options::Query::BuildDeferredIndexes.new)
150
+ @backend.collection_query_index_build_deferred(@bucket_name, @scope_name, @collection_name, options.to_backend)
151
+ end
152
+
153
+ # Polls indexes until they are online
154
+ #
155
+ # @param [Array<String>] index_names names of the indexes to watch
156
+ # @param [Integer, #in_milliseconds] timeout the time in milliseconds allowed for the operation to complete
157
+ # @param [Options::Query::WatchIndexes] options
158
+ #
159
+ # @raise [ArgumentError]
160
+ # @raise [Error::IndexNotFound]
161
+ def watch_indexes(index_names, timeout, options = Options::Query::WatchIndexes.new)
162
+ index_names.append("#primary") if options.watch_primary
163
+
164
+ interval_millis = 50
165
+ deadline = Time.now + (Utils::Time.extract_duration(timeout) * 0.001)
166
+ while Time.now <= deadline
167
+ get_all_opts = Options::Query::GetAllIndexes.new(timeout: ((deadline - Time.now) * 1000).round)
168
+ indexes = get_all_indexes(get_all_opts).select { |idx| index_names.include? idx.name }
169
+ indexes_not_found = index_names - indexes.map(&:name)
170
+ raise Error::IndexNotFound, "Failed to find the indexes: #{indexes_not_found.join(', ')}" unless indexes_not_found.empty?
171
+
172
+ all_online = indexes.all? { |idx| idx.state == :online }
173
+ return if all_online
174
+
175
+ sleep(interval_millis / 1000)
176
+ interval_millis += 500
177
+ interval_millis = 1000 if interval_millis > 1000
178
+ end
179
+ raise Error::UnambiguousTimeout, "Failed to find all indexes online within the allotted time"
180
+ end
181
+ end
182
+ end
183
+ end
@@ -14,6 +14,7 @@
14
14
 
15
15
  require "couchbase/errors"
16
16
  require "couchbase/options"
17
+ require "couchbase/utils/time"
17
18
 
18
19
  module Couchbase
19
20
  module Management
@@ -371,6 +372,10 @@ module Couchbase
371
372
  # @raise [ArgumentError]
372
373
  # @raise [Error::IndexExists]
373
374
  def create_index(bucket_name, index_name, fields, options = Options::Query::CreateIndex.new)
375
+ unless options.scope_name.nil? && options.collection_name.nil?
376
+ warn "The attributes 'scope_name' and 'collection_name' have been deprecated. Use 'collection.query_indexes' instead"
377
+ end
378
+
374
379
  @backend.query_index_create(bucket_name, index_name, fields, options.to_backend)
375
380
  end
376
381
 
@@ -384,6 +389,10 @@ module Couchbase
384
389
  # @raise [ArgumentError]
385
390
  # @raise [Error::IndexExists]
386
391
  def create_primary_index(bucket_name, options = Options::Query::CreatePrimaryIndex.new)
392
+ unless options.scope_name.nil? && options.collection_name.nil?
393
+ warn "The attributes 'scope_name' and 'collection_name' have been deprecated. Use 'collection.query_indexes' instead"
394
+ end
395
+
387
396
  @backend.query_index_create_primary(bucket_name, options.to_backend)
388
397
  end
389
398
 
@@ -398,8 +407,11 @@ module Couchbase
398
407
  # @raise [ArgumentError]
399
408
  # @raise [Error::IndexNotFound]
400
409
  def drop_index(bucket_name, index_name, options = Options::Query::DropIndex.new)
410
+ unless options.scope_name.nil? && options.collection_name.nil?
411
+ warn "The attributes 'scope_name' and 'collection_name' have been deprecated. Use 'collection.query_indexes' instead"
412
+ end
413
+
401
414
  @backend.query_index_drop(bucket_name, index_name, options.to_backend)
402
- true
403
415
  end
404
416
 
405
417
  # Drops the primary index
@@ -412,8 +424,11 @@ module Couchbase
412
424
  # @raise [ArgumentError]
413
425
  # @raise [Error::IndexNotFound]
414
426
  def drop_primary_index(bucket_name, options = Options::Query::DropPrimaryIndex.new)
427
+ unless options.scope_name.nil? && options.collection_name.nil?
428
+ warn "The attributes 'scope_name' and 'collection_name' have been deprecated. Use 'collection.query_indexes' instead"
429
+ end
430
+
415
431
  @backend.query_index_drop_primary(bucket_name, options.to_backend)
416
- true
417
432
  end
418
433
 
419
434
  # Build all indexes which are currently in deferred state
@@ -438,7 +453,24 @@ module Couchbase
438
453
  # @raise [ArgumentError]
439
454
  # @raise [Error::IndexNotFound]
440
455
  def watch_indexes(bucket_name, index_names, timeout, options = Options::Query::WatchIndexes.new)
441
- @backend.query_index_watch(bucket_name, index_names, Utils::Time.extract_duration(timeout), options.to_backend)
456
+ index_names.append("#primary") if options.watch_primary
457
+
458
+ interval_millis = 50
459
+ deadline = Time.now + (Utils::Time.extract_duration(timeout) * 0.001)
460
+ while Time.now <= deadline
461
+ get_all_opts = Options::Query::GetAllIndexes.new(timeout: ((deadline - Time.now) * 1000).round)
462
+ indexes = get_all_indexes(bucket_name, get_all_opts).select { |idx| index_names.include? idx.name }
463
+ indexes_not_found = index_names - indexes.map(&:name)
464
+ raise Error::IndexNotFound, "Failed to find the indexes: #{indexes_not_found.join(', ')}" unless indexes_not_found.empty?
465
+
466
+ all_online = indexes.all? { |idx| idx.state == :online }
467
+ return if all_online
468
+
469
+ sleep(interval_millis / 1000)
470
+ interval_millis += 500
471
+ interval_millis = 1000 if interval_millis > 1000
472
+ end
473
+ raise Error::UnambiguousTimeout, "Failed to find all indexes online within the allotted time"
442
474
  end
443
475
 
444
476
  # @api private
@@ -22,6 +22,7 @@ require "couchbase/management/analytics_index_manager"
22
22
  require "couchbase/management/bucket_manager"
23
23
  require "couchbase/management/collection_manager"
24
24
  require "couchbase/management/query_index_manager"
25
+ require "couchbase/management/collection_query_index_manager"
25
26
  require "couchbase/management/search_index_manager"
26
27
  require "couchbase/management/user_manager"
27
28
  require "couchbase/management/view_index_manager"
@@ -2091,7 +2091,7 @@ module Couchbase
2091
2091
  attr_reader :scan_consistency
2092
2092
 
2093
2093
  # @api private
2094
- def to_backend(scope_name: nil)
2094
+ def to_backend(*)
2095
2095
  {
2096
2096
  timeout: Utils::Time.extract_duration(@timeout),
2097
2097
  limit: @limit,
@@ -2099,8 +2099,7 @@ module Couchbase
2099
2099
  explain: @explain,
2100
2100
  disable_scoring: @disable_scoring,
2101
2101
  include_locations: @include_locations,
2102
- scope: scope_name,
2103
- collections: scope_name ? @collections : nil,
2102
+ collections: @collections,
2104
2103
  highlight_style: @highlight_style,
2105
2104
  highlight_fields: @highlight_fields,
2106
2105
  fields: @fields,
@@ -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.0".freeze)
22
+ VERSION.update(:sdk => "3.4.1".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.0
4
+ version: 3.4.1
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-02-19 00:00:00.000000000 Z
11
+ date: 2023-03-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Modern SDK for Couchbase Server
14
14
  email:
@@ -47,6 +47,7 @@ files:
47
47
  - lib/couchbase/management/analytics_index_manager.rb
48
48
  - lib/couchbase/management/bucket_manager.rb
49
49
  - lib/couchbase/management/collection_manager.rb
50
+ - lib/couchbase/management/collection_query_index_manager.rb
50
51
  - lib/couchbase/management/query_index_manager.rb
51
52
  - lib/couchbase/management/search_index_manager.rb
52
53
  - lib/couchbase/management/user_manager.rb
@@ -72,9 +73,9 @@ metadata:
72
73
  homepage_uri: https://docs.couchbase.com/ruby-sdk/current/hello-world/start-using-sdk.html
73
74
  bug_tracker_uri: https://couchbase.com/issues/browse/RCBC
74
75
  mailing_list_uri: https://forums.couchbase.com/c/ruby-sdk
75
- source_code_uri: https://github.com/couchbase/couchbase-ruby-client/tree/3.4.0
76
- changelog_uri: https://github.com/couchbase/couchbase-ruby-client/releases/tag/3.4.0
77
- documentation_uri: https://docs.couchbase.com/sdk-api/couchbase-ruby-client-3.4.0/index.html
76
+ source_code_uri: https://github.com/couchbase/couchbase-ruby-client/tree/3.4.1
77
+ changelog_uri: https://github.com/couchbase/couchbase-ruby-client/releases/tag/3.4.1
78
+ documentation_uri: https://docs.couchbase.com/sdk-api/couchbase-ruby-client-3.4.1/index.html
78
79
  github_repo: ssh://github.com/couchbase/couchbase-ruby-client
79
80
  rubygems_mfa_required: 'true'
80
81
  post_install_message: