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,247 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 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 "couchbase/management/query_index_manager"
18
+ require "couchbase/utils/time"
19
+ require "couchbase/errors"
20
+
21
+ module Couchbase
22
+ module Management
23
+ class CollectionQueryIndexManager
24
+ alias inspect to_s
25
+
26
+ # @param [Couchbase::Backend] backend
27
+ # @param [String] bucket_name name of the bucket
28
+ # @param [String] scope_name name of the scope
29
+ # @param [String] collection_name name of the collection
30
+ # @param [Observability::Wrapper] observability wrapper
31
+ #
32
+ # @api private
33
+ def initialize(backend, bucket_name, scope_name, collection_name, observability)
34
+ @backend = backend
35
+ @bucket_name = bucket_name
36
+ @scope_name = scope_name
37
+ @collection_name = collection_name
38
+ @observability = observability
39
+ end
40
+
41
+ # Fetches all indexes from the server
42
+ #
43
+ # @param [Options::Query::GetAllIndexes] options
44
+ #
45
+ # @return [Array<QueryIndex>]
46
+ #
47
+ # @raise [Error::InvalidArgument]
48
+ def get_all_indexes(options = Options::Query::GetAllIndexes.new)
49
+ unless options.scope_name.nil?
50
+ raise Error::InvalidArgument,
51
+ "Scope name cannot be set in the options when using the Query Index manager at the collection level"
52
+ end
53
+
54
+ unless options.collection_name.nil?
55
+ raise Error::InvalidArgument,
56
+ "Collection name cannot be set in the options when using the Query Index manager at the collection level"
57
+ end
58
+
59
+ @observability.record_operation(Observability::OP_QM_GET_ALL_INDEXES, options.parent_span, self, :query) do |obs_handler|
60
+ res = @backend.collection_query_index_get_all(@bucket_name, @scope_name, @collection_name, options.to_backend, obs_handler)
61
+ res[:indexes].map do |idx|
62
+ QueryIndex.new do |index|
63
+ index.name = idx[:name]
64
+ index.is_primary = idx[:is_primary]
65
+ index.type = idx[:type]
66
+ index.state = idx[:state]
67
+ index.bucket = idx[:bucket_name]
68
+ index.scope = idx[:scope_name]
69
+ index.collection = idx[:collection_name]
70
+ index.index_key = idx[:index_key]
71
+ index.condition = idx[:condition]
72
+ index.partition = idx[:partition]
73
+ end
74
+ end
75
+ end
76
+ end
77
+
78
+ # Creates a new index
79
+ #
80
+ # @param [String] index_name name of the index
81
+ # @param [Array<String>] fields the lists of fields to create th index over
82
+ # @param [Options::Query::CreateIndex] options
83
+ #
84
+ # @return void
85
+ #
86
+ # @raise [Error::InvalidArgument]
87
+ # @raise [Error::IndexExists]
88
+ def create_index(index_name, fields, options = Options::Query::CreateIndex.new)
89
+ unless options.scope_name.nil?
90
+ raise Error::InvalidArgument,
91
+ "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 Error::InvalidArgument,
96
+ "Collection name cannot be set in the options when using the Query Index manager at the collection level"
97
+ end
98
+
99
+ @observability.record_operation(Observability::OP_QM_CREATE_INDEX, options.parent_span, self, :query) do |obs_handler|
100
+ @backend.collection_query_index_create(@bucket_name, @scope_name, @collection_name, index_name, fields, options.to_backend,
101
+ obs_handler)
102
+ end
103
+ end
104
+
105
+ # Creates new primary index
106
+ #
107
+ # @param [Options::Query::CreatePrimaryIndex] options
108
+ #
109
+ # @return void
110
+ #
111
+ # @raise [Error::InvalidArgument]
112
+ # @raise [Error::IndexExists]
113
+ def create_primary_index(options = Options::Query::CreatePrimaryIndex.new)
114
+ unless options.scope_name.nil?
115
+ raise Error::InvalidArgument,
116
+ "Scope name cannot be set in the options when using the Query Index manager at the collection level"
117
+ end
118
+
119
+ unless options.collection_name.nil?
120
+ raise Error::InvalidArgument,
121
+ "Collection name cannot be set in the options when using the Query Index manager at the collection level"
122
+ end
123
+
124
+ @observability.record_operation(Observability::OP_QM_CREATE_PRIMARY_INDEX, options.parent_span, self, :query) do |obs_handler|
125
+ @backend.collection_query_index_create_primary(@bucket_name, @scope_name, @collection_name, options.to_backend, obs_handler)
126
+ end
127
+ end
128
+
129
+ # Drops the index
130
+ #
131
+ # @param [String] index_name name of the index
132
+ # @param [Options::Query::DropIndex] options
133
+ #
134
+ # @return void
135
+ #
136
+ # @raise [Error::InvalidArgument]
137
+ # @raise [Error::IndexNotFound]
138
+ def drop_index(index_name, options = Options::Query::DropIndex.new)
139
+ unless options.scope_name.nil?
140
+ raise Error::InvalidArgument,
141
+ "Scope name cannot be set in the options when using the Query Index manager at the collection level"
142
+ end
143
+
144
+ unless options.collection_name.nil?
145
+ raise Error::InvalidArgument,
146
+ "Collection name cannot be set in the options when using the Query Index manager at the collection level"
147
+ end
148
+
149
+ @observability.record_operation(Observability::OP_QM_DROP_INDEX, options.parent_span, self, :query) do |obs_handler|
150
+ @backend.collection_query_index_drop(@bucket_name, @scope_name, @collection_name, index_name, options.to_backend, obs_handler)
151
+ end
152
+ end
153
+
154
+ # Drops the primary index
155
+ #
156
+ # @param [Options::Query::DropPrimaryIndex] options
157
+ #
158
+ # @return void
159
+ #
160
+ # @raise [Error::InvalidArgument]
161
+ # @raise [Error::IndexNotFound]
162
+ def drop_primary_index(options = Options::Query::DropPrimaryIndex.new)
163
+ unless options.scope_name.nil?
164
+ raise Error::InvalidArgument,
165
+ "Scope name cannot be set in the options when using the Query Index manager at the collection level"
166
+ end
167
+
168
+ unless options.collection_name.nil?
169
+ raise Error::InvalidArgument,
170
+ "Collection name cannot be set in the options when using the Query Index manager at the collection level"
171
+ end
172
+
173
+ @observability.record_operation(Observability::OP_QM_DROP_PRIMARY_INDEX, options.parent_span, self, :query) do |obs_handler|
174
+ @backend.collection_query_index_drop_primary(@bucket_name, @scope_name, @collection_name, options.to_backend, obs_handler)
175
+ end
176
+ end
177
+
178
+ # Build all indexes which are currently in deferred state
179
+ #
180
+ # @param [Options::Query::BuildDeferredIndexes] options
181
+ #
182
+ # @return void
183
+ #
184
+ # @raise [Error::InvalidArgument]
185
+ def build_deferred_indexes(options = Options::Query::BuildDeferredIndexes.new)
186
+ unless options.scope_name.nil?
187
+ raise Error::InvalidArgument,
188
+ "Scope name cannot be set in the options when using the Query Index manager at the collection level"
189
+ end
190
+
191
+ unless options.collection_name.nil?
192
+ raise Error::InvalidArgument,
193
+ "Collection name cannot be set in the options when using the Query Index manager at the collection level"
194
+ end
195
+
196
+ @observability.record_operation(Observability::OP_QM_BUILD_DEFERRED_INDEXES, options.parent_span, self, :query) do |obs_handler|
197
+ @backend.collection_query_index_build_deferred(@bucket_name, @scope_name, @collection_name, options.to_backend, obs_handler)
198
+ end
199
+ end
200
+
201
+ # Polls indexes until they are online
202
+ #
203
+ # @param [Array<String>] index_names names of the indexes to watch
204
+ # @param [Integer, #in_milliseconds] timeout the time in milliseconds allowed for the operation to complete
205
+ # @param [Options::Query::WatchIndexes] options
206
+ #
207
+ # @raise [Error::InvalidArgument]
208
+ # @raise [Error::IndexNotFound]
209
+ def watch_indexes(index_names, timeout, options = Options::Query::WatchIndexes.new)
210
+ unless options.scope_name.nil?
211
+ raise Error::InvalidArgument,
212
+ "Scope name cannot be set in the options when using the Query Index manager at the collection level"
213
+ end
214
+
215
+ unless options.collection_name.nil?
216
+ raise Error::InvalidArgument,
217
+ "Collection name cannot be set in the options when using the Query Index manager at the collection level"
218
+ end
219
+
220
+ @observability.record_operation(Observability::OP_QM_WATCH_INDEXES, options.parent_span, self, :query) do |obs_handler|
221
+ index_names.append("#primary") if options.watch_primary
222
+
223
+ interval_millis = 50
224
+ deadline = Time.now + (Utils::Time.extract_duration(timeout) * 0.001)
225
+ all_online = false
226
+ while Time.now <= deadline
227
+ get_all_opts = Options::Query::GetAllIndexes.new(
228
+ timeout: ((deadline - Time.now) * 1000).round,
229
+ parent_span: obs_handler.op_span,
230
+ )
231
+ indexes = get_all_indexes(get_all_opts).select { |idx| index_names.include? idx.name }
232
+ indexes_not_found = index_names - indexes.map(&:name)
233
+ raise Error::IndexNotFound, "Failed to find the indexes: #{indexes_not_found.join(', ')}" unless indexes_not_found.empty?
234
+
235
+ all_online = indexes.all? { |idx| idx.state == :online }
236
+ break if all_online
237
+
238
+ sleep(interval_millis / 1000)
239
+ interval_millis += 500
240
+ interval_millis = 1000 if interval_millis > 1000
241
+ end
242
+ raise Error::UnambiguousTimeout, "Failed to find all indexes online within the allotted time" unless all_online
243
+ end
244
+ end
245
+ end
246
+ end
247
+ end