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,183 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020-2021 Couchbase, Inc.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ module Couchbase
18
+ class DiagnosticsResult
19
+ class ServiceInfo
20
+ # @return [String] endpoint unique identifier
21
+ attr_accessor :id
22
+
23
+ # Possible states are:
24
+ #
25
+ # :disconnected:: the endpoint is not reachable
26
+ # :connecting:: currently connecting (includes auth, handshake, etc.)
27
+ # :connected:: connected and ready
28
+ # :disconnecting:: disconnecting (after being connected)
29
+ #
30
+ # @return [Symbol] state of the endpoint
31
+ attr_accessor :state
32
+
33
+ # @return [String, nil] optional string with additional explanation for the state
34
+ attr_accessor :details
35
+
36
+ # @return [Integer] how long ago the endpoint was active (in microseconds)
37
+ attr_accessor :last_activity_us
38
+
39
+ # @return [String] remote address of the connection
40
+ attr_accessor :remote
41
+
42
+ # @return [String] local address of the connection
43
+ attr_accessor :local
44
+
45
+ # @yieldparam [ServiceInfo] self
46
+ def initialize
47
+ yield self if block_given?
48
+ end
49
+
50
+ def to_json(*)
51
+ data = {
52
+ id: @id,
53
+ state: @state,
54
+ remote: @remote,
55
+ local: @local,
56
+ }
57
+ data[:details] = @details if @details
58
+ data[:last_activity_us] = @last_activity_us if @last_activity_us
59
+ data.to_json(*)
60
+ end
61
+ end
62
+
63
+ # @return [String] report id
64
+ attr_accessor :id
65
+
66
+ # @return [String] SDK identifier
67
+ attr_accessor :sdk
68
+
69
+ # Returns information about currently service endpoints, that known to the library at the moment.
70
+ #
71
+ # :kv:: Key/Value data service
72
+ # :query:: N1QL query service
73
+ # :analytics:: Analtyics service
74
+ # :search:: Full text search service
75
+ # :views:: Views service
76
+ # :mgmt:: Management service
77
+ #
78
+ # @return [Hash<Symbol, ServiceInfo>] map service types to info
79
+ attr_accessor :services
80
+
81
+ # @yieldparam [DiagnosticsResult] self
82
+ def initialize
83
+ @services = {}
84
+ yield self if block_given?
85
+ end
86
+
87
+ # @api private
88
+ # @return [Integer] version
89
+ attr_accessor :version
90
+
91
+ def to_json(*)
92
+ {
93
+ version: @version,
94
+ id: @id,
95
+ sdk: @sdk,
96
+ services: @services,
97
+ }.to_json(*)
98
+ end
99
+ end
100
+
101
+ class PingResult
102
+ class ServiceInfo
103
+ # @return [String] endpoint unique identifier
104
+ attr_accessor :id
105
+
106
+ # Possible states are:
107
+ #
108
+ # :ok:: endpoint is healthy
109
+ # :timeout:: endpoint didn't respond in time
110
+ # :error:: request to endpoint has failed, see {#error} for additional details
111
+ #
112
+ # @return [Symbol] state of the endpoint
113
+ attr_accessor :state
114
+
115
+ # @return [String, nil] optional string with additional explanation for the state
116
+ attr_accessor :error
117
+
118
+ # @return [Integer] how long ago the endpoint was active (in microseconds)
119
+ attr_accessor :latency
120
+
121
+ # @return [String] remote address of the connection
122
+ attr_accessor :remote
123
+
124
+ # @return [String] local address of the connection
125
+ attr_accessor :local
126
+
127
+ # @yieldparam [ServiceInfo] self
128
+ def initialize
129
+ @error = nil
130
+ yield self if block_given?
131
+ end
132
+
133
+ def to_json(*)
134
+ data = {
135
+ id: @id,
136
+ state: @state,
137
+ remote: @remote,
138
+ local: @local,
139
+ latency: @latency,
140
+ }
141
+ data[:error] = @error if @error
142
+ data.to_json(*)
143
+ end
144
+ end
145
+
146
+ # @return [String] report id
147
+ attr_accessor :id
148
+
149
+ # @return [String] SDK identifier
150
+ attr_accessor :sdk
151
+
152
+ # Returns information about currently service endpoints, that known to the library at the moment.
153
+ #
154
+ # :kv:: Key/Value data service
155
+ # :query:: N1QL query service
156
+ # :analytics:: Analtyics service
157
+ # :search:: Full text search service
158
+ # :views:: Views service
159
+ # :mgmt:: Management service
160
+ #
161
+ # @return [Hash<Symbol, ServiceInfo>] map service types to info
162
+ attr_accessor :services
163
+
164
+ # @yieldparam [DiagnosticsResult] self
165
+ def initialize
166
+ @services = {}
167
+ yield self if block_given?
168
+ end
169
+
170
+ # @api private
171
+ # @return [Integer] version
172
+ attr_accessor :version
173
+
174
+ def to_json(*)
175
+ {
176
+ version: @version,
177
+ id: @id,
178
+ sdk: @sdk,
179
+ services: @services,
180
+ }.to_json(*)
181
+ end
182
+ end
183
+ end
@@ -0,0 +1,438 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020-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 "json"
18
+
19
+ module Couchbase
20
+ # This namespace contains all error types that the library might raise.
21
+ module Error
22
+ class CouchbaseError < StandardError
23
+ # @return [Hash, nil] attributes associated with the error
24
+ attr_reader :context
25
+
26
+ # @return [CouchbaseError, nil] original error that caused this one
27
+ attr_reader :cause
28
+
29
+ def initialize(msg = nil, context = nil, cause = nil)
30
+ @context = context
31
+ @cause = cause
32
+ super(msg)
33
+ end
34
+
35
+ def context=(context)
36
+ return unless context.is_a?(String)
37
+
38
+ @context =
39
+ begin
40
+ JSON.parse(context)
41
+ rescue StandardError
42
+ context
43
+ end
44
+ end
45
+
46
+ def to_s
47
+ result = +super
48
+ result << ", context=#{JSON.generate(@context)}" if @context
49
+ result << ", cause=#{@cause}" if @cause
50
+ result
51
+ end
52
+ end
53
+
54
+ class InvalidArgument < ArgumentError
55
+ # @return [Hash, nil] attributes associated with the error
56
+ attr_reader :context
57
+
58
+ # @return [CouchbaseError, nil] original error that caused this one
59
+ attr_reader :cause
60
+
61
+ def initialize(msg = nil, context = nil, cause = nil)
62
+ @context = context
63
+ @cause = cause
64
+ super(msg)
65
+ end
66
+
67
+ def context=(context)
68
+ return unless context.is_a?(String)
69
+
70
+ @context =
71
+ begin
72
+ JSON.parse(context)
73
+ rescue StandardError
74
+ context
75
+ end
76
+ end
77
+
78
+ def to_s
79
+ result = super
80
+ result << ", context=#{JSON.generate(@context)}" if @context
81
+ result << ", cause=#{@cause}" if @cause
82
+ result
83
+ end
84
+ end
85
+
86
+ # Common exceptions
87
+
88
+ class RequestCanceled < CouchbaseError
89
+ end
90
+
91
+ class ServiceNotAvailable < CouchbaseError
92
+ end
93
+
94
+ # Indicates an operation failed because there has been an internal error in the server.
95
+ class InternalServerFailure < CouchbaseError
96
+ end
97
+
98
+ # Every exception that has to do with authentication problems should either instantiate or subclass from this type.
99
+ class AuthenticationFailure < CouchbaseError
100
+ end
101
+
102
+ # Indicates that the user has insufficient permissions to perform the operation
103
+ #
104
+ # @!macro uncommitted
105
+ class PermissionDenied < CouchbaseError
106
+ end
107
+
108
+ class TemporaryFailure < CouchbaseError
109
+ end
110
+
111
+ # Indicates an operation failed because parsing of the input returned with an error.
112
+ class ParsingFailure < CouchbaseError
113
+ end
114
+
115
+ # Indicates an optimistic locking failure.
116
+ #
117
+ # The operation failed because the specified compare and swap (CAS) value differs from the document's actual CAS
118
+ # value. This means the document was modified since the original CAS value was acquired.
119
+ #
120
+ # The application should usually respond by fetching a fresh version of the document and repeating the failed
121
+ # operation.
122
+ class CasMismatch < CouchbaseError
123
+ end
124
+
125
+ class BucketNotFound < CouchbaseError
126
+ end
127
+
128
+ class CollectionNotFound < CouchbaseError
129
+ end
130
+
131
+ class ScopeNotFound < CouchbaseError
132
+ end
133
+
134
+ class IndexNotFound < CouchbaseError
135
+ end
136
+
137
+ class IndexExists < CouchbaseError
138
+ end
139
+
140
+ # Raised when provided content could not be successfully encoded.
141
+ class EncodingFailure < CouchbaseError
142
+ end
143
+
144
+ # Raised when provided content could not be successfully decoded.
145
+ class DecodingFailure < CouchbaseError
146
+ end
147
+
148
+ class UnsupportedOperation < CouchbaseError
149
+ end
150
+
151
+ # The {Timeout} signals that an operation timed out before it could be completed.
152
+ #
153
+ # It is important to understand that the timeout itself is always just the effect an underlying cause, never the
154
+ # issue itself. The root cause might not even be on the application side, also the network and server need to be
155
+ # taken into account.
156
+ #
157
+ # Right now the SDK can throw two different implementations of this class:
158
+ #
159
+ # {AmbiguousTimeout}::
160
+ # The operation might have caused a side effect on the server and should not be retried without
161
+ # actions and checks.
162
+ #
163
+ # {UnambiguousTimeout}::
164
+ # The operation has not caused a side effect on the server and is safe to retry. This is always the case for
165
+ # idempotent operations. For non-idempotent operations it depends on the state the operation was in at the time of
166
+ # cancellation.
167
+ class Timeout < CouchbaseError
168
+ end
169
+
170
+ # This is a special case of the timeout exception, signaling that the timeout happened with an ambiguous cause.
171
+ class AmbiguousTimeout < Timeout
172
+ end
173
+
174
+ # This is a special case of the timeout exception, signaling that the timeout happened with no ambiguous cause.
175
+ class UnambiguousTimeout < Timeout
176
+ end
177
+
178
+ # Exception which states that the feature is not available.
179
+ class FeatureNotAvailable < CouchbaseError
180
+ end
181
+
182
+ # KeyValue exceptions
183
+
184
+ # Indicates an operation failed because the key does not exist.
185
+ class DocumentNotFound < CouchbaseError
186
+ end
187
+
188
+ # Indicates that the replica selected by {Collection#get_replica} does not hold the document.
189
+ #
190
+ # @since 3.9.0
191
+ class DocumentNotFoundOnReplica < DocumentNotFound
192
+ end
193
+
194
+ # Indicates that {Collection#get_replica} requested a replica the bucket is not configured with.
195
+ #
196
+ # @since 3.9.0
197
+ class ReplicaIndexOutOfBounds < CouchbaseError
198
+ end
199
+
200
+ # Indicates that {Collection#get_replica} requested a configured replica. The vbucket map places it on no node.
201
+ #
202
+ # @since 3.9.0
203
+ class ReplicaIndexCurrentlyUnavailable < CouchbaseError
204
+ end
205
+
206
+ # Indicates an operation completed but no successful document was retrievable.
207
+ class DocumentIrretrievable < CouchbaseError
208
+ end
209
+
210
+ # Thrown when the server reports a temporary failure that is very likely to be lock-related (like an already locked
211
+ # key or a bad cas used for unlock).
212
+ #
213
+ # See https://issues.couchbase.com/browse/MB-13087 for an explanation of why this is only _likely_ to be
214
+ # lock-related.
215
+ class DocumentLocked < CouchbaseError
216
+ end
217
+
218
+ # Thrown when the server reports that the document is not locked when an unlocking operation is being performed.
219
+ class DocumentNotLocked < CouchbaseError
220
+ end
221
+
222
+ # Thrown when the request is too big for some reason.
223
+ class ValueTooLarge < CouchbaseError
224
+ end
225
+
226
+ # Indicates an operation failed because the key already exists.
227
+ class DocumentExists < CouchbaseError
228
+ end
229
+
230
+ # This exception is raised when a durability level has been requested that is not available on the server.
231
+ class DurabilityLevelNotAvailable < CouchbaseError
232
+ end
233
+
234
+ # The given durability requirements are currently impossible to achieve, as not enough configured replicas are
235
+ # currently available.
236
+ class DurabilityImpossible < CouchbaseError
237
+ end
238
+
239
+ # The synchronous replication durability work can return an ambiguous error (or we timeout waiting for the response,
240
+ # which is effectively the same). Here we know the change is on a majority of replicas, or it's on none.
241
+ class DurabilityAmbiguous < CouchbaseError
242
+ end
243
+
244
+ # Returned if an attempt is made to mutate a key which already has a durable write pending.
245
+ class DurableWriteInProgress < CouchbaseError
246
+ end
247
+
248
+ # The requested key has a SyncWrite which is being re-committed.
249
+ class DurableWriteReCommitInProgress < CouchbaseError
250
+ end
251
+
252
+ # Happens when consistency requirements are specified but the partition uuid of the requirements do not align
253
+ # with the server
254
+ class MutationTokenOutdated < CouchbaseError
255
+ end
256
+
257
+ # Subdocument exception thrown when a path does not exist in the document. The exact meaning of path existence
258
+ # depends on the operation and inputs.
259
+ class PathNotFound < CouchbaseError
260
+ end
261
+
262
+ # Subdocument exception thrown when the path structure conflicts with the document structure (for example, if a
263
+ # path mentions foo.bar[0].baz, but foo.bar is actually a JSON object).
264
+ class PathMismatch < CouchbaseError
265
+ end
266
+
267
+ # Subdocument exception thrown when path has a syntax error, or path syntax is incorrect for the operation (for
268
+ # example, if operation requires an array index).
269
+ class PathInvalid < CouchbaseError
270
+ end
271
+
272
+ # Subdocument exception thrown when path is too deep to parse. Depth of a path is determined by how many components
273
+ # (or levels) it contains.
274
+ #
275
+ # The current limitation is there to ensure a single parse does not consume too much memory (overloading the
276
+ # server). This error is similar to other TooDeep errors, which all relate to various validation stages to ensure
277
+ # the server does not consume too much memory when parsing a single document.
278
+ class PathTooDeep < CouchbaseError
279
+ end
280
+
281
+ class PathTooBig < CouchbaseError
282
+ end
283
+
284
+ # Subdocument exception thrown when proposed value would make the document too deep to parse.
285
+ #
286
+ # The current limitation is there to ensure a single parse does not consume too much memory (overloading the
287
+ # server). This error is similar to other TooDeep errors, which all relate to various validation stages to ensure
288
+ # the server does not consume too much memory when parsing a single document.
289
+ class ValueTooDeep < CouchbaseError
290
+ end
291
+
292
+ # Subdocument exception thrown when the provided value cannot be inserted at the given path.
293
+ #
294
+ # It is actually thrown when the delta in an counter operation is valid, but applying that delta would
295
+ # result in an out-of-range number (server interprets numbers as 64-bit integers).
296
+ class ValueInvalid < CouchbaseError
297
+ end
298
+
299
+ # Subdocument exception thrown when the targeted enclosing document itself is not JSON.
300
+ class DocumentNotJson < CouchbaseError
301
+ end
302
+
303
+ # Subdocument exception thrown when existing number value in document is too big.
304
+ #
305
+ # The value is interpreted as 64 bit on the server side.
306
+ class NumberTooBig < CouchbaseError
307
+ end
308
+
309
+ # Subdocument exception thrown when the delta in an arithmetic operation (eg counter) is invalid. In this SDK, this
310
+ # is equivalent to saying that the delta is zero.
311
+ #
312
+ # Note that the server also returns the corresponding error code when the delta value itself is too big, or not a
313
+ # number, but since the SDK enforces deltas to be of type long, these cases shouldn't come up.
314
+ class DeltaInvalid < CouchbaseError
315
+ end
316
+
317
+ # Subdocument exception thrown when a path already exists and it shouldn't
318
+ class PathExists < CouchbaseError
319
+ end
320
+
321
+ # Subdocument exception thrown when a macro has been requested which is not recognised by the server.
322
+ class XattrUnknownMacro < CouchbaseError
323
+ end
324
+
325
+ # Subdocument exception thrown when more than one xattr key has been requested.
326
+ class XattrInvalidKeyCombo < CouchbaseError
327
+ end
328
+
329
+ # Subdocument exception thrown when a virtual attribute has been requested which is not recognised by the server.
330
+ class XattrUnknownVirtualAttribute < CouchbaseError
331
+ end
332
+
333
+ # Subdocument exception thrown when the virtual attribute cannot be modified.
334
+ class XattrCannotModifyVirtualAttribute < CouchbaseError
335
+ end
336
+
337
+ # Query exceptions
338
+
339
+ # Indicates an operation failed because there has been an issue with the query planner.
340
+ class PlanningFailure < CouchbaseError
341
+ end
342
+
343
+ # Indicates an operation failed because there has been an issue with the query planner or similar.
344
+ class IndexFailure < CouchbaseError
345
+ end
346
+
347
+ # Indicates an operation failed because there has been an issue with query prepared statements.
348
+ class PreparedStatementFailure < CouchbaseError
349
+ end
350
+
351
+ # Analytics exceptions
352
+
353
+ # The analytics query failed to compile.
354
+ class CompilationFailure < CouchbaseError
355
+ end
356
+
357
+ # Indicates the analytics server job queue is full
358
+ class JobQueueFull < CouchbaseError
359
+ end
360
+
361
+ # The queried dataset is not found on the server.
362
+ class DatasetNotFound < CouchbaseError
363
+ end
364
+
365
+ class DatasetExists < CouchbaseError
366
+ end
367
+
368
+ class DataverseExists < CouchbaseError
369
+ end
370
+
371
+ class DataverseNotFound < CouchbaseError
372
+ end
373
+
374
+ class LinkNotFound < CouchbaseError
375
+ end
376
+
377
+ class LinkExists < CouchbaseError
378
+ end
379
+
380
+ # Search exceptions
381
+
382
+ class IndexNotReady < CouchbaseError
383
+ end
384
+
385
+ class ConsistencyMismatch < CouchbaseError
386
+ end
387
+
388
+ # View exceptions
389
+
390
+ class DesignDocumentNotFound < CouchbaseError
391
+ end
392
+
393
+ # The queried view is not found on the server
394
+ class ViewNotFound < CouchbaseError
395
+ end
396
+
397
+ # Management exceptions
398
+
399
+ class CollectionExists < CouchbaseError
400
+ end
401
+
402
+ class ScopeExists < CouchbaseError
403
+ end
404
+
405
+ class UserExists < CouchbaseError
406
+ end
407
+
408
+ class BucketExists < CouchbaseError
409
+ end
410
+
411
+ class BucketNotFlushable < CouchbaseError
412
+ end
413
+
414
+ class GroupNotFound < CouchbaseError
415
+ end
416
+
417
+ class UserNotFound < CouchbaseError
418
+ end
419
+
420
+ # Library-specific exceptions
421
+
422
+ class BackendError < CouchbaseError
423
+ end
424
+
425
+ # Environment name string cannot be determined
426
+ class NoEnvironment < CouchbaseError
427
+ end
428
+
429
+ class ClusterClosed < CouchbaseError
430
+ end
431
+
432
+ class TracerError < CouchbaseError
433
+ end
434
+
435
+ class MeterError < CouchbaseError
436
+ end
437
+ end
438
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020-2025 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
+ module Couchbase
18
+ module ForkHooks
19
+ def _fork
20
+ # :prepare stops the instances and only :parent or :child restarts them, so an asynchronous
21
+ # exception is deferred everywhere except inside the fork itself.
22
+ Thread.handle_interrupt(Object => :never) do
23
+ parent_pid = Process.pid
24
+ Couchbase::Backend.notify_fork(:prepare)
25
+ begin
26
+ Thread.handle_interrupt(Object => :immediate) do
27
+ # A check point: an interrupt deferred during :prepare lands here, before the fork.
28
+ Thread.pass
29
+ super
30
+ end
31
+ ensure
32
+ # Decided by pid rather than by the return value, which an exception raised after the fork
33
+ # never delivers.
34
+ Couchbase::Backend.notify_fork(Process.pid == parent_pid ? :parent : :child)
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+
41
+ Process.singleton_class.prepend(Couchbase::ForkHooks)