couchbase 3.9.0-aarch64-mingw-ucrt

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 (147) 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.4/libcouchbase.so +0 -0
  7. data/lib/couchbase/4.0/libcouchbase.so +0 -0
  8. data/lib/couchbase/analytics_options.rb +109 -0
  9. data/lib/couchbase/authenticator.rb +80 -0
  10. data/lib/couchbase/binary_collection.rb +145 -0
  11. data/lib/couchbase/binary_collection_options.rb +26 -0
  12. data/lib/couchbase/bucket.rb +173 -0
  13. data/lib/couchbase/cluster.rb +555 -0
  14. data/lib/couchbase/cluster_registry.rb +49 -0
  15. data/lib/couchbase/collection.rb +770 -0
  16. data/lib/couchbase/collection_options.rb +401 -0
  17. data/lib/couchbase/config_profiles.rb +57 -0
  18. data/lib/couchbase/configuration.rb +58 -0
  19. data/lib/couchbase/datastructures/couchbase_list.rb +192 -0
  20. data/lib/couchbase/datastructures/couchbase_map.rb +231 -0
  21. data/lib/couchbase/datastructures/couchbase_queue.rb +161 -0
  22. data/lib/couchbase/datastructures/couchbase_set.rb +145 -0
  23. data/lib/couchbase/datastructures.rb +26 -0
  24. data/lib/couchbase/deprecations.rb +61 -0
  25. data/lib/couchbase/diagnostics.rb +183 -0
  26. data/lib/couchbase/errors.rb +438 -0
  27. data/lib/couchbase/fork_hooks.rb +41 -0
  28. data/lib/couchbase/get_replica_strategy.rb +89 -0
  29. data/lib/couchbase/json_transcoder.rb +41 -0
  30. data/lib/couchbase/key_value_scan.rb +119 -0
  31. data/lib/couchbase/libcouchbase.rb +6 -0
  32. data/lib/couchbase/logger.rb +87 -0
  33. data/lib/couchbase/management/analytics_index_manager.rb +1160 -0
  34. data/lib/couchbase/management/bucket_manager.rb +479 -0
  35. data/lib/couchbase/management/collection_manager.rb +515 -0
  36. data/lib/couchbase/management/collection_query_index_manager.rb +247 -0
  37. data/lib/couchbase/management/query_index_manager.rb +671 -0
  38. data/lib/couchbase/management/scope_search_index_manager.rb +267 -0
  39. data/lib/couchbase/management/search_index_manager.rb +649 -0
  40. data/lib/couchbase/management/user_manager.rb +639 -0
  41. data/lib/couchbase/management/view_index_manager.rb +332 -0
  42. data/lib/couchbase/management.rb +31 -0
  43. data/lib/couchbase/metrics/logging_meter.rb +108 -0
  44. data/lib/couchbase/metrics/logging_value_recorder.rb +50 -0
  45. data/lib/couchbase/metrics/meter.rb +27 -0
  46. data/lib/couchbase/metrics/noop_meter.rb +30 -0
  47. data/lib/couchbase/metrics/noop_value_recorder.rb +27 -0
  48. data/lib/couchbase/metrics/value_recorder.rb +25 -0
  49. data/lib/couchbase/mutation_state.rb +65 -0
  50. data/lib/couchbase/options.rb +3097 -0
  51. data/lib/couchbase/protostellar/binary_collection.rb +55 -0
  52. data/lib/couchbase/protostellar/bucket.rb +59 -0
  53. data/lib/couchbase/protostellar/client.rb +97 -0
  54. data/lib/couchbase/protostellar/cluster.rb +182 -0
  55. data/lib/couchbase/protostellar/collection.rb +156 -0
  56. data/lib/couchbase/protostellar/connect_options.rb +63 -0
  57. data/lib/couchbase/protostellar/error_handling.rb +204 -0
  58. data/lib/couchbase/protostellar/generated/admin/analytics/v1/analytics_pb.rb +54 -0
  59. data/lib/couchbase/protostellar/generated/admin/analytics/v1/analytics_services_pb.rb +51 -0
  60. data/lib/couchbase/protostellar/generated/admin/bucket/v1/bucket_pb.rb +42 -0
  61. data/lib/couchbase/protostellar/generated/admin/bucket/v1/bucket_services_pb.rb +51 -0
  62. data/lib/couchbase/protostellar/generated/admin/collection/v1/collection_pb.rb +38 -0
  63. data/lib/couchbase/protostellar/generated/admin/collection/v1/collection_services_pb.rb +52 -0
  64. data/lib/couchbase/protostellar/generated/admin/query/v1/query_pb.rb +42 -0
  65. data/lib/couchbase/protostellar/generated/admin/query/v1/query_services_pb.rb +55 -0
  66. data/lib/couchbase/protostellar/generated/admin/search/v1/search_pb.rb +51 -0
  67. data/lib/couchbase/protostellar/generated/admin/search/v1/search_services_pb.rb +67 -0
  68. data/lib/couchbase/protostellar/generated/analytics/v1/analytics_pb.rb +31 -0
  69. data/lib/couchbase/protostellar/generated/analytics/v1/analytics_services_pb.rb +40 -0
  70. data/lib/couchbase/protostellar/generated/internal/hooks/v1/hooks_pb.rb +51 -0
  71. data/lib/couchbase/protostellar/generated/internal/hooks/v1/hooks_services_pb.rb +54 -0
  72. data/lib/couchbase/protostellar/generated/internal/xdcr/v1/xdcr_pb.rb +46 -0
  73. data/lib/couchbase/protostellar/generated/internal/xdcr/v1/xdcr_services_pb.rb +56 -0
  74. data/lib/couchbase/protostellar/generated/kv/v1/kv_pb.rb +74 -0
  75. data/lib/couchbase/protostellar/generated/kv/v1/kv_services_pb.rb +93 -0
  76. data/lib/couchbase/protostellar/generated/query/v1/query_pb.rb +35 -0
  77. data/lib/couchbase/protostellar/generated/query/v1/query_services_pb.rb +40 -0
  78. data/lib/couchbase/protostellar/generated/routing/v2/routing_pb.rb +26 -0
  79. data/lib/couchbase/protostellar/generated/routing/v2/routing_services_pb.rb +43 -0
  80. data/lib/couchbase/protostellar/generated/search/v1/search_pb.rb +78 -0
  81. data/lib/couchbase/protostellar/generated/search/v1/search_services_pb.rb +41 -0
  82. data/lib/couchbase/protostellar/generated/transactions/v1/transactions_pb.rb +36 -0
  83. data/lib/couchbase/protostellar/generated/transactions/v1/transactions_services_pb.rb +66 -0
  84. data/lib/couchbase/protostellar/generated/view/v1/view_pb.rb +30 -0
  85. data/lib/couchbase/protostellar/generated/view/v1/view_services_pb.rb +39 -0
  86. data/lib/couchbase/protostellar/generated.rb +9 -0
  87. data/lib/couchbase/protostellar/management/bucket_manager.rb +67 -0
  88. data/lib/couchbase/protostellar/management/collection_manager.rb +94 -0
  89. data/lib/couchbase/protostellar/management/collection_query_index_manager.rb +124 -0
  90. data/lib/couchbase/protostellar/management/query_index_manager.rb +112 -0
  91. data/lib/couchbase/protostellar/management.rb +24 -0
  92. data/lib/couchbase/protostellar/request.rb +79 -0
  93. data/lib/couchbase/protostellar/request_behaviour.rb +42 -0
  94. data/lib/couchbase/protostellar/request_generator/admin/bucket.rb +124 -0
  95. data/lib/couchbase/protostellar/request_generator/admin/collection.rb +96 -0
  96. data/lib/couchbase/protostellar/request_generator/admin/query.rb +132 -0
  97. data/lib/couchbase/protostellar/request_generator/admin.rb +24 -0
  98. data/lib/couchbase/protostellar/request_generator/kv.rb +488 -0
  99. data/lib/couchbase/protostellar/request_generator/query.rb +133 -0
  100. data/lib/couchbase/protostellar/request_generator/search.rb +403 -0
  101. data/lib/couchbase/protostellar/request_generator.rb +26 -0
  102. data/lib/couchbase/protostellar/response_converter/admin/bucket.rb +55 -0
  103. data/lib/couchbase/protostellar/response_converter/admin/collection.rb +42 -0
  104. data/lib/couchbase/protostellar/response_converter/admin/query.rb +59 -0
  105. data/lib/couchbase/protostellar/response_converter/admin.rb +24 -0
  106. data/lib/couchbase/protostellar/response_converter/kv.rb +151 -0
  107. data/lib/couchbase/protostellar/response_converter/query.rb +84 -0
  108. data/lib/couchbase/protostellar/response_converter/search.rb +136 -0
  109. data/lib/couchbase/protostellar/response_converter.rb +26 -0
  110. data/lib/couchbase/protostellar/retry/action.rb +38 -0
  111. data/lib/couchbase/protostellar/retry/orchestrator.rb +61 -0
  112. data/lib/couchbase/protostellar/retry/reason.rb +67 -0
  113. data/lib/couchbase/protostellar/retry/strategies/best_effort.rb +49 -0
  114. data/lib/couchbase/protostellar/retry/strategies/fail_fast.rb +33 -0
  115. data/lib/couchbase/protostellar/retry/strategies.rb +27 -0
  116. data/lib/couchbase/protostellar/retry.rb +28 -0
  117. data/lib/couchbase/protostellar/scope.rb +61 -0
  118. data/lib/couchbase/protostellar/timeout_defaults.rb +30 -0
  119. data/lib/couchbase/protostellar/timeouts.rb +83 -0
  120. data/lib/couchbase/protostellar.rb +29 -0
  121. data/lib/couchbase/query_options.rb +122 -0
  122. data/lib/couchbase/railtie.rb +47 -0
  123. data/lib/couchbase/raw_binary_transcoder.rb +39 -0
  124. data/lib/couchbase/raw_json_transcoder.rb +40 -0
  125. data/lib/couchbase/raw_string_transcoder.rb +42 -0
  126. data/lib/couchbase/scope.rb +272 -0
  127. data/lib/couchbase/search_options.rb +1744 -0
  128. data/lib/couchbase/subdoc.rb +293 -0
  129. data/lib/couchbase/tracing/noop_span.rb +29 -0
  130. data/lib/couchbase/tracing/noop_tracer.rb +29 -0
  131. data/lib/couchbase/tracing/request_span.rb +34 -0
  132. data/lib/couchbase/tracing/request_tracer.rb +28 -0
  133. data/lib/couchbase/tracing/threshold_logging_span.rb +112 -0
  134. data/lib/couchbase/tracing/threshold_logging_tracer.rb +231 -0
  135. data/lib/couchbase/transcoder_flags.rb +64 -0
  136. data/lib/couchbase/utils/generic_logger_adapter.rb +40 -0
  137. data/lib/couchbase/utils/hdr_histogram.rb +55 -0
  138. data/lib/couchbase/utils/observability.rb +263 -0
  139. data/lib/couchbase/utils/observability_constants.rb +200 -0
  140. data/lib/couchbase/utils/stdlib_logger_adapter.rb +65 -0
  141. data/lib/couchbase/utils/time.rb +71 -0
  142. data/lib/couchbase/utils.rb +23 -0
  143. data/lib/couchbase/version.rb +25 -0
  144. data/lib/couchbase/view_options.rb +67 -0
  145. data/lib/couchbase.rb +32 -0
  146. data/lib/rails/generators/couchbase/config/config_generator.rb +29 -0
  147. metadata +209 -0
@@ -0,0 +1,145 @@
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
+ require "couchbase/options"
18
+ require "couchbase/binary_collection_options"
19
+
20
+ module Couchbase
21
+ # Allows to perform certain operations on non-JSON documents.
22
+ class BinaryCollection
23
+ alias inspect to_s
24
+
25
+ # @param [Couchbase::Collection] collection parent collection
26
+ #
27
+ # @api private
28
+ def initialize(collection)
29
+ @collection = collection
30
+ @backend = collection.instance_variable_get(:@backend)
31
+ @observability = collection.instance_variable_get(:@observability)
32
+ end
33
+
34
+ # Appends binary content to the document
35
+ #
36
+ # @param [String] id the document id which is used to uniquely identify it
37
+ # @param [String] content the binary content to append to the document
38
+ # @param [Options::Append] options custom options to customize the request
39
+ #
40
+ # @example Append "bar" to the content of the existing document
41
+ # collection.upsert("mydoc", "foo")
42
+ # collection.binary.append("mydoc", "bar", Options::Append(timeout: 3_000))
43
+ # collection.get("mydoc", Options::Get(transcoder: nil)).content #=> "foobar"
44
+ #
45
+ # @return [Collection::MutationResult]
46
+ def append(id, content, options = Options::Append::DEFAULT)
47
+ @observability.record_operation(Observability::OP_APPEND, options.parent_span, self, :kv) do |obs_handler|
48
+ obs_handler.add_durability_level(options.durability_level)
49
+ resp = @backend.document_append(@collection.bucket_name, @collection.scope_name, @collection.name,
50
+ id, content, options.to_backend, obs_handler)
51
+ Collection::MutationResult.new do |res|
52
+ res.cas = resp[:cas]
53
+ res.mutation_token = @collection.send(:extract_mutation_token, resp)
54
+ end
55
+ end
56
+ end
57
+
58
+ # Prepends binary content to the document
59
+ #
60
+ # @param [String] id the document id which is used to uniquely identify it
61
+ # @param [String] content the binary content to prepend to the document
62
+ # @param [Options::Prepend] options custom options to customize the request
63
+ #
64
+ # @example Prepend "bar" to the content of the existing document
65
+ # collection.upsert("mydoc", "foo")
66
+ # collection.binary.prepend("mydoc", "bar", Options::Prepend(timeout: 3_000))
67
+ # collection.get("mydoc", Options::Get(transcoder: nil)).content #=> "barfoo"
68
+ #
69
+ # @return [Collection::MutationResult]
70
+ def prepend(id, content, options = Options::Prepend::DEFAULT)
71
+ @observability.record_operation(Observability::OP_PREPEND, options.parent_span, self, :kv) do |obs_handler|
72
+ obs_handler.add_durability_level(options.durability_level)
73
+ resp = @backend.document_prepend(@collection.bucket_name, @collection.scope_name, @collection.name,
74
+ id, content, options.to_backend, obs_handler)
75
+ Collection::MutationResult.new do |res|
76
+ res.cas = resp[:cas]
77
+ res.mutation_token = @collection.send(:extract_mutation_token, resp)
78
+ end
79
+ end
80
+ end
81
+
82
+ # Increments the counter document by one of the number defined in the options
83
+ #
84
+ # @param [String] id the document id which is used to uniquely identify it
85
+ # @param [Options::Increment] options custom options to customize the request
86
+ #
87
+ # @example Increment value by 10, and initialize to 0 if it does not exist
88
+ # res = collection.binary.increment("raw_counter", Options::Increment(delta: 10, initial: 0))
89
+ # res.content #=> 0
90
+ # res = collection.binary.increment("raw_counter", Options::Increment(delta: 10, initial: 0))
91
+ # res.content #=> 10
92
+ #
93
+ # @return [CounterResult]
94
+ def increment(id, options = Options::Increment::DEFAULT)
95
+ @observability.record_operation(Observability::OP_INCREMENT, options.parent_span, self, :kv) do |obs_handler|
96
+ obs_handler.add_durability_level(options.durability_level)
97
+ resp = @backend.document_increment(@collection.bucket_name, @collection.scope_name, @collection.name, id,
98
+ options.to_backend, obs_handler)
99
+ CounterResult.new do |res|
100
+ res.cas = resp[:cas]
101
+ res.content = resp[:content]
102
+ res.mutation_token = @collection.send(:extract_mutation_token, resp)
103
+ end
104
+ end
105
+ end
106
+
107
+ # Decrements the counter document by one of the number defined in the options
108
+ #
109
+ # @param [String] id the document id which is used to uniquely identify it
110
+ # @param [Options::Decrement] options custom options to customize the request
111
+ #
112
+ # @example Decrement value by 2, and initialize to 100 if it does not exist
113
+ # res = collection.binary.decrement("raw_counter", Options::Decrement(delta: 2, initial: 100))
114
+ # res.value #=> 100
115
+ # res = collection.binary.decrement("raw_counter", Options::Decrement(delta: 2, initial: 100))
116
+ # res.value #=> 98
117
+ #
118
+ # @return [CounterResult]
119
+ def decrement(id, options = Options::Decrement::DEFAULT)
120
+ @observability.record_operation(Observability::OP_DECREMENT, options.parent_span, self, :kv) do |obs_handler|
121
+ obs_handler.add_durability_level(options.durability_level)
122
+ resp = @backend.document_decrement(@collection.bucket_name, @collection.scope_name, @collection.name, id,
123
+ options.to_backend, obs_handler)
124
+ CounterResult.new do |res|
125
+ res.cas = resp[:cas]
126
+ res.content = resp[:content]
127
+ res.mutation_token = @collection.send(:extract_mutation_token, resp)
128
+ end
129
+ end
130
+ end
131
+
132
+ # @api private
133
+ # TODO: deprecate in 3.1
134
+ AppendOptions = ::Couchbase::Options::Append
135
+ # @api private
136
+ # TODO: deprecate in 3.1
137
+ PrependOptions = ::Couchbase::Options::Prepend
138
+ # @api private
139
+ # TODO: deprecate in 3.1
140
+ IncrementOptions = ::Couchbase::Options::Increment
141
+ # @api private
142
+ # TODO: deprecate in 3.1
143
+ DecrementOptions = ::Couchbase::Options::Decrement
144
+ end
145
+ end
@@ -0,0 +1,26 @@
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
+ require "couchbase/collection_options"
18
+
19
+ module Couchbase
20
+ class BinaryCollection
21
+ class CounterResult < ::Couchbase::Collection::MutationResult
22
+ # @return [Integer] current value of the counter
23
+ attr_accessor :content
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,173 @@
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
+ require "couchbase/scope"
18
+ require "couchbase/management/collection_manager"
19
+ require "couchbase/management/view_index_manager"
20
+ require "couchbase/options"
21
+ require "couchbase/view_options"
22
+ require "couchbase/diagnostics"
23
+
24
+ module Couchbase
25
+ # Provides access to a Couchbase bucket APIs
26
+ class Bucket
27
+ # @return [String] name of the bucket
28
+ attr_reader :name
29
+
30
+ alias inspect to_s
31
+
32
+ # @param [Couchbase::Backend] backend
33
+ #
34
+ # @api private
35
+ def initialize(backend, name, observability)
36
+ backend.open_bucket(name, true)
37
+ @backend = backend
38
+ @name = name
39
+ @observability = observability
40
+ end
41
+
42
+ # Get default scope
43
+ #
44
+ # @return [Scope]
45
+ def default_scope
46
+ Scope.new(@backend, @name, "_default", @observability)
47
+ end
48
+
49
+ # Get a named scope
50
+ #
51
+ # @param [String] scope_name name of the scope
52
+ #
53
+ # @return [Scope]
54
+ def scope(scope_name)
55
+ Scope.new(@backend, @name, scope_name, @observability)
56
+ end
57
+
58
+ # Opens the named collection in the default scope of the bucket
59
+ #
60
+ # @param [String] collection_name name of the collection
61
+ #
62
+ # @return [Collection]
63
+ def collection(collection_name)
64
+ default_scope.collection(collection_name)
65
+ end
66
+
67
+ # Opens the default collection for this bucket
68
+ #
69
+ # @return [Collection]
70
+ def default_collection
71
+ Collection.new(@backend, @name, "_default", "_default", @observability)
72
+ end
73
+
74
+ # Performs query to view index.
75
+ #
76
+ # @param [String] design_document_name name of the design document
77
+ # @param [String] view_name name of the view to query
78
+ # @param [Options::View] options
79
+ #
80
+ # @example Make sure the view engine catch up with all mutations and return keys starting from +["random_brewery:"]+
81
+ # bucket.view_query("beer", "brewery_beers",
82
+ # Options::View(
83
+ # start_key: ["random_brewery:"],
84
+ # scan_consistency: :request_plus
85
+ # ))
86
+ #
87
+ # @return [ViewResult]
88
+ #
89
+ # @deprecated Views are deprecated in Couchbase Server 7.0+, and will be removed from a future server version.
90
+ # Views are not compatible with the Magma storage engine. Instead of views, use indexes and queries using the
91
+ # Index Service (GSI) and the Query Service (SQL++).
92
+ def view_query(design_document_name, view_name, options = Options::View::DEFAULT)
93
+ @observability.record_operation(Observability::OP_VIEW_QUERY, options.parent_span, self, :views) do |obs_handler|
94
+ resp = @backend.document_view(@name, design_document_name, view_name, options.namespace, options.to_backend, obs_handler)
95
+ ViewResult.new do |res|
96
+ res.meta_data = ViewMetaData.new do |meta|
97
+ meta.total_rows = resp[:meta][:total_rows]
98
+ meta.debug_info = resp[:meta][:debug_info]
99
+ end
100
+ res.rows = resp[:rows].map do |entry|
101
+ ViewRow.new do |row|
102
+ row.id = entry[:id] if entry.key?(:id)
103
+ row.key = JSON.parse(entry[:key])
104
+ row.value = JSON.parse(entry[:value])
105
+ end
106
+ end
107
+ end
108
+ end
109
+ end
110
+
111
+ # @return [Management::CollectionManager]
112
+ def collections
113
+ Management::CollectionManager.new(@backend, @name, @observability)
114
+ end
115
+
116
+ # @return [Management::ViewIndexManager]
117
+ #
118
+ # @deprecated Views are deprecated in Couchbase Server 7.0+, and will be removed from a future server version.
119
+ # Views are not compatible with the Magma storage engine. Instead of views, use indexes and queries using the
120
+ # Index Service (GSI) and the Query Service (SQL++).
121
+ def view_indexes
122
+ Management::ViewIndexManager.new(@backend, @name, @observability)
123
+ end
124
+
125
+ # Performs application-level ping requests against services in the couchbase cluster
126
+ #
127
+ # @param [Options::Ping] options
128
+ #
129
+ # @return [PingResult]
130
+ def ping(options = Options::Ping::DEFAULT)
131
+ @observability.record_operation(Observability::OP_PING, options.parent_span, self) do |_obs_handler|
132
+ resp = @backend.ping(@name, options.to_backend)
133
+ PingResult.new do |res|
134
+ res.version = resp[:version]
135
+ res.id = resp[:id]
136
+ res.sdk = resp[:sdk]
137
+ resp[:services].each do |type, svcs|
138
+ res.services[type] = svcs.map do |svc|
139
+ PingResult::ServiceInfo.new do |info|
140
+ info.id = svc[:id]
141
+ info.state = svc[:state]
142
+ info.latency = svc[:latency]
143
+ info.remote = svc[:remote]
144
+ info.local = svc[:local]
145
+ info.error = svc[:error]
146
+ end
147
+ end
148
+ end
149
+ end
150
+ end
151
+ end
152
+
153
+ # Waits until the bucket reaches the desired state, actively pinging its services
154
+ #
155
+ # With +:online+, the wait also requires the bucket's vbucket map to be placed: every vbucket has its active copy
156
+ # and each replica the data nodes can hold assigned to a node. +:degraded+ only pings.
157
+ #
158
+ # +Thread#raise+ does not interrupt the wait. It ends on success, on +timeout+, or when the cluster is disconnected.
159
+ #
160
+ # @param [Integer, #in_milliseconds] timeout the maximum time to wait
161
+ # @param [Options::WaitUntilReady] options
162
+ #
163
+ # @return [void]
164
+ #
165
+ # @raise [Error::UnambiguousTimeout] if the desired state is not reached within +timeout+
166
+ # @raise [Error::ClusterClosed] if the cluster has been disconnected
167
+ # @raise [Error::InvalidArgument] if +timeout+ is negative or longer than 365 days, or +options+ name an
168
+ # unsupported desired state or service type
169
+ def wait_until_ready(timeout, options = Options::WaitUntilReady::DEFAULT)
170
+ @backend.wait_until_ready(@name, Utils::Time.extract_duration(timeout), options.to_backend)
171
+ end
172
+ end
173
+ end