couchbase 4.7.0 → 4.7.1

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 (69) hide show
  1. package/deps/couchbase-cxx-cache/mozilla-ca-bundle.crt +3 -575
  2. package/deps/couchbase-cxx-cache/mozilla-ca-bundle.sha256 +1 -1
  3. package/deps/couchbase-cxx-client/CMakeLists.txt +3 -1
  4. package/deps/couchbase-cxx-client/README.md +2 -2
  5. package/deps/couchbase-cxx-client/core/error_context/base_error_context.hxx +32 -0
  6. package/deps/couchbase-cxx-client/core/error_context/key_value.cxx +1 -0
  7. package/deps/couchbase-cxx-client/core/error_context/key_value.hxx +23 -0
  8. package/deps/couchbase-cxx-client/core/error_context/key_value_error_context.hxx +35 -0
  9. package/deps/couchbase-cxx-client/core/error_context/subdocument_error_context.hxx +41 -0
  10. package/deps/couchbase-cxx-client/core/impl/binary_collection.cxx +123 -88
  11. package/deps/couchbase-cxx-client/core/impl/collection.cxx +416 -189
  12. package/deps/couchbase-cxx-client/core/impl/error.cxx +29 -4
  13. package/deps/couchbase-cxx-client/core/impl/invoke_with_node_id.hxx +44 -0
  14. package/deps/couchbase-cxx-client/core/impl/node_id.cxx +110 -0
  15. package/deps/couchbase-cxx-client/core/impl/node_id.hxx +40 -0
  16. package/deps/couchbase-cxx-client/core/io/configuration_belongs_to_session.hxx +67 -0
  17. package/deps/couchbase-cxx-client/core/io/http_session_manager.hxx +97 -57
  18. package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +7 -16
  19. package/deps/couchbase-cxx-client/core/operations/document_get_all_replicas.hxx +14 -4
  20. package/deps/couchbase-cxx-client/core/operations/document_get_projected.cxx +3 -4
  21. package/deps/couchbase-cxx-client/core/operations/document_lookup_in_all_replicas.hxx +4 -0
  22. package/deps/couchbase-cxx-client/core/operations/document_query.cxx +12 -12
  23. package/deps/couchbase-cxx-client/core/operations/management/collection_create.cxx +11 -11
  24. package/deps/couchbase-cxx-client/core/operations/management/collection_drop.cxx +11 -11
  25. package/deps/couchbase-cxx-client/core/operations/management/collection_update.cxx +11 -11
  26. package/deps/couchbase-cxx-client/core/operations/management/error_utils.cxx +9 -6
  27. package/deps/couchbase-cxx-client/core/operations/management/query_index_create.cxx +5 -4
  28. package/deps/couchbase-cxx-client/core/operations/management/query_index_drop.cxx +7 -6
  29. package/deps/couchbase-cxx-client/core/operations/management/scope_create.cxx +12 -13
  30. package/deps/couchbase-cxx-client/core/operations/management/scope_drop.cxx +8 -9
  31. package/deps/couchbase-cxx-client/core/topology/configuration.cxx +21 -0
  32. package/deps/couchbase-cxx-client/core/topology/configuration.hxx +28 -0
  33. package/deps/couchbase-cxx-client/core/utils/contains_string.cxx +61 -0
  34. package/deps/couchbase-cxx-client/core/utils/contains_string.hxx +26 -0
  35. package/deps/couchbase-cxx-client/couchbase/collection.hxx +73 -0
  36. package/deps/couchbase-cxx-client/couchbase/error.hxx +16 -0
  37. package/deps/couchbase-cxx-client/couchbase/node_id.hxx +123 -0
  38. package/deps/couchbase-cxx-client/couchbase/node_id_for_options.hxx +61 -0
  39. package/deps/couchbase-cxx-client/couchbase/node_ids_options.hxx +62 -0
  40. package/deps/couchbase-cxx-client/couchbase/result.hxx +42 -0
  41. package/dist/binding.d.ts +1 -0
  42. package/dist/bucket.d.ts +9 -1
  43. package/dist/bucket.js +21 -0
  44. package/dist/cluster.d.ts +10 -1
  45. package/dist/cluster.js +22 -0
  46. package/dist/collection.d.ts +3 -3
  47. package/dist/collection.js +161 -123
  48. package/dist/diagnosticsexecutor.js +2 -2
  49. package/dist/diagnosticstypes.d.ts +36 -0
  50. package/dist/diagnosticstypes.js +22 -1
  51. package/dist/observability.d.ts +5 -1
  52. package/dist/observability.js +11 -3
  53. package/dist/observabilityhandler.d.ts +6 -0
  54. package/dist/observabilityhandler.js +51 -14
  55. package/dist/observabilitytypes.js +19 -42
  56. package/dist/observabilityutilities.js +1 -1
  57. package/dist/oteltracer.d.ts +5 -0
  58. package/dist/oteltracer.js +7 -0
  59. package/dist/queryindexmanager.js +15 -0
  60. package/dist/thresholdlogging.d.ts +5 -0
  61. package/dist/thresholdlogging.js +7 -0
  62. package/dist/tracing.d.ts +6 -0
  63. package/dist/version.d.ts +1 -1
  64. package/dist/version.js +1 -1
  65. package/dist/waituntilreadyexecutor.d.ts +37 -0
  66. package/dist/waituntilreadyexecutor.js +156 -0
  67. package/package.json +8 -8
  68. package/scripts/prebuilds.js +13 -0
  69. package/src/binding.cpp +1 -1
@@ -35,6 +35,8 @@
35
35
  #include <couchbase/lookup_in_specs.hxx>
36
36
  #include <couchbase/mutate_in_options.hxx>
37
37
  #include <couchbase/mutate_in_specs.hxx>
38
+ #include <couchbase/node_id_for_options.hxx>
39
+ #include <couchbase/node_ids_options.hxx>
38
40
  #include <couchbase/query_options.hxx>
39
41
  #include <couchbase/remove_options.hxx>
40
42
  #include <couchbase/replace_options.hxx>
@@ -1090,6 +1092,77 @@ public:
1090
1092
  [[nodiscard]] auto scan(const scan_type& scan_type, const scan_options& options = {}) const
1091
1093
  -> std::future<std::pair<error, scan_result>>;
1092
1094
 
1095
+ /**
1096
+ * Resolves a document key to the identity of the cluster node that currently
1097
+ * owns it, using the client-side vBucket map (no network round-trip).
1098
+ *
1099
+ * @param document_id the document id to resolve
1100
+ * @param options options to customize the request
1101
+ * @param handler the handler that receives the result
1102
+ *
1103
+ * @since 1.3.2
1104
+ * @uncommitted
1105
+ */
1106
+ void node_id_for(std::string document_id,
1107
+ const node_id_for_options& options,
1108
+ node_id_for_handler&& handler) const;
1109
+
1110
+ /**
1111
+ * Resolves a document key to the identity of the cluster node that currently
1112
+ * owns it, using the client-side vBucket map (no network round-trip).
1113
+ *
1114
+ * @param document_id the document id to resolve
1115
+ * @param options options to customize the request
1116
+ * @return future carrying the error (if any) and node_id
1117
+ *
1118
+ * @since 1.3.2
1119
+ * @uncommitted
1120
+ */
1121
+ [[nodiscard]] auto node_id_for(std::string document_id,
1122
+ const node_id_for_options& options = {}) const
1123
+ -> std::future<std::pair<error, node_id>>;
1124
+
1125
+ /**
1126
+ * Returns the set of cluster nodes that currently serve key-value
1127
+ * traffic for this collection's bucket, drawn from the client-side
1128
+ * topology snapshot (no network round-trip).
1129
+ *
1130
+ * Each entry corresponds to one cluster node and is the same node_id
1131
+ * the SDK reports on KV results and errors that touched that node, so
1132
+ * the returned set is directly comparable to the keys of any
1133
+ * application-side state that is keyed by node_id (e.g. a per-node
1134
+ * circuit breaker registry). A periodic sweep that diffs the
1135
+ * registry's keys against this set is the canonical way to retire
1136
+ * tracker state for a node that has been removed from the cluster
1137
+ * topology.
1138
+ *
1139
+ * Nodes that do not expose a key-value port for the configured
1140
+ * transport (TLS or plain) are excluded from the returned set, since
1141
+ * they do not serve KV operations and therefore have no meaningful
1142
+ * identity from the SDK's point of view.
1143
+ *
1144
+ * @param options options to customize the request
1145
+ * @param handler the handler that receives the result
1146
+ *
1147
+ * @since 1.3.2
1148
+ * @uncommitted
1149
+ */
1150
+ void node_ids(const node_ids_options& options, node_ids_handler&& handler) const;
1151
+
1152
+ /**
1153
+ * Returns the set of cluster nodes that currently serve key-value
1154
+ * traffic for this collection's bucket, drawn from the client-side
1155
+ * topology snapshot (no network round-trip).
1156
+ *
1157
+ * @param options options to customize the request
1158
+ * @return future carrying the error (if any) and the set of node_ids
1159
+ *
1160
+ * @since 1.3.2
1161
+ * @uncommitted
1162
+ */
1163
+ [[nodiscard]] auto node_ids(const node_ids_options& options = {}) const
1164
+ -> std::future<std::pair<error, std::vector<node_id>>>;
1165
+
1093
1166
  [[nodiscard]] auto query_indexes() const -> collection_query_index_manager;
1094
1167
 
1095
1168
  private:
@@ -18,6 +18,7 @@
18
18
  #pragma once
19
19
 
20
20
  #include <couchbase/error_context.hxx>
21
+ #include <couchbase/node_id.hxx>
21
22
 
22
23
  #include <memory>
23
24
  #include <optional>
@@ -32,12 +33,26 @@ public:
32
33
  error() = default;
33
34
  error(std::error_code ec, std::string message = {}, error_context ctx = {});
34
35
  error(std::error_code ec, std::string message, error_context ctx, error cause);
36
+ error(std::error_code ec, std::string message, error_context ctx, couchbase::node_id node_id);
35
37
 
36
38
  [[nodiscard]] auto ec() const -> std::error_code;
37
39
  [[nodiscard]] auto message() const -> const std::string&;
38
40
  [[nodiscard]] auto ctx() const -> const error_context&;
39
41
  [[nodiscard]] auto cause() const -> std::optional<error>;
40
42
 
43
+ /**
44
+ * Returns the identity of the cluster node where the error occurred.
45
+ *
46
+ * The returned node_id is default-constructed (falsy) when the node
47
+ * could not be determined (e.g. for non-KV errors).
48
+ *
49
+ * @return identity of the node that returned the error
50
+ *
51
+ * @since 1.3.2
52
+ * @uncommitted
53
+ */
54
+ [[nodiscard]] auto node_id() const -> const couchbase::node_id&;
55
+
41
56
  explicit operator bool() const;
42
57
  auto operator==(const error& other) const -> bool;
43
58
 
@@ -46,6 +61,7 @@ private:
46
61
  std::string message_{};
47
62
  error_context ctx_{};
48
63
  std::shared_ptr<error> cause_{};
64
+ couchbase::node_id node_id_{};
49
65
  };
50
66
 
51
67
  } // namespace couchbase
@@ -0,0 +1,123 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2024-Present 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
+
18
+ #pragma once
19
+
20
+ #include <cstdint>
21
+ #include <functional>
22
+ #include <string>
23
+
24
+ namespace couchbase
25
+ {
26
+
27
+ /**
28
+ * Uniquely identifies a cluster node.
29
+ *
30
+ * On Couchbase Server 8.0.1+ the identifier is the server-assigned node UUID.
31
+ * On older releases, a stable opaque token is derived from the node's hostname
32
+ * and management port.
33
+ *
34
+ * The type is equality-comparable, ordered, and hashable.
35
+ *
36
+ * @since 1.3.2
37
+ * @uncommitted
38
+ */
39
+ class node_id
40
+ {
41
+ public:
42
+ /**
43
+ * Creates an empty (invalid) node_id.
44
+ *
45
+ * @since 1.3.2
46
+ * @uncommitted
47
+ */
48
+ node_id() = default;
49
+
50
+ /**
51
+ * User-facing identifier string.
52
+ *
53
+ * Returns node_uuid when the server provides one, otherwise a stable
54
+ * hex-encoded hash derived from hostname and management port.
55
+ *
56
+ * @return opaque identifier string (empty for default-constructed instances)
57
+ *
58
+ * @since 1.3.2
59
+ * @uncommitted
60
+ */
61
+ [[nodiscard]] auto id() const -> const std::string&;
62
+
63
+ /**
64
+ * The server-assigned node UUID (empty on servers before 8.0.1).
65
+ *
66
+ * @since 1.3.2
67
+ * @uncommitted
68
+ */
69
+ [[nodiscard]] auto node_uuid() const -> const std::string&;
70
+
71
+ /**
72
+ * The hostname of the node.
73
+ *
74
+ * @since 1.3.2
75
+ * @uncommitted
76
+ */
77
+ [[nodiscard]] auto hostname() const -> const std::string&;
78
+
79
+ /**
80
+ * The port of the node's key-value service.
81
+ *
82
+ * This reflects the port actually used by the client: the TLS port when the
83
+ * cluster connection is TLS-enabled, otherwise the plain port.
84
+ *
85
+ * @since 1.3.2
86
+ * @uncommitted
87
+ */
88
+ [[nodiscard]] auto port() const -> std::uint16_t;
89
+
90
+ /**
91
+ * Returns true when the node_id was properly initialized (not default-constructed).
92
+ *
93
+ * @since 1.3.2
94
+ * @uncommitted
95
+ */
96
+ explicit operator bool() const;
97
+
98
+ auto operator==(const node_id& other) const -> bool;
99
+ auto operator!=(const node_id& other) const -> bool;
100
+ auto operator<(const node_id& other) const -> bool;
101
+
102
+ private:
103
+ friend class internal_node_id;
104
+
105
+ node_id(std::string node_uuid, std::string hostname, std::uint16_t port);
106
+
107
+ std::string node_uuid_{};
108
+ std::string hostname_{};
109
+ std::uint16_t port_{ 0 };
110
+ // Computed once at construction: node_uuid_ if non-empty, otherwise a
111
+ // deterministic hex-encoded CRC32 hash of "hostname:port".
112
+ std::string id_{};
113
+ };
114
+
115
+ } // namespace couchbase
116
+
117
+ template<>
118
+ struct std::hash<couchbase::node_id> {
119
+ auto operator()(const couchbase::node_id& nid) const noexcept -> std::size_t
120
+ {
121
+ return std::hash<std::string>{}(nid.id());
122
+ }
123
+ };
@@ -0,0 +1,61 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2024-Present 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
+
18
+ #pragma once
19
+
20
+ #include <couchbase/common_options.hxx>
21
+ #include <couchbase/error.hxx>
22
+ #include <couchbase/node_id.hxx>
23
+
24
+ #include <functional>
25
+
26
+ namespace couchbase
27
+ {
28
+
29
+ /**
30
+ * Options for @ref collection#node_id_for().
31
+ *
32
+ * @since 1.3.2
33
+ * @uncommitted
34
+ */
35
+ struct node_id_for_options : public common_options<node_id_for_options> {
36
+ /**
37
+ * Immutable value object representing consistent options.
38
+ *
39
+ * @since 1.3.2
40
+ * @internal
41
+ */
42
+ struct built : public common_options<node_id_for_options>::built {
43
+ };
44
+
45
+ /**
46
+ * Validates options and returns them as an immutable value.
47
+ *
48
+ * @return consistent options as an immutable value
49
+ *
50
+ * @since 1.3.2
51
+ * @internal
52
+ */
53
+ [[nodiscard]] auto build() const -> built
54
+ {
55
+ return { build_common_options() };
56
+ }
57
+ };
58
+
59
+ using node_id_for_handler = std::function<void(error, node_id)>;
60
+
61
+ } // namespace couchbase
@@ -0,0 +1,62 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2024-Present 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
+
18
+ #pragma once
19
+
20
+ #include <couchbase/common_options.hxx>
21
+ #include <couchbase/error.hxx>
22
+ #include <couchbase/node_id.hxx>
23
+
24
+ #include <functional>
25
+ #include <vector>
26
+
27
+ namespace couchbase
28
+ {
29
+
30
+ /**
31
+ * Options for @ref collection#node_ids().
32
+ *
33
+ * @since 1.3.2
34
+ * @uncommitted
35
+ */
36
+ struct node_ids_options : public common_options<node_ids_options> {
37
+ /**
38
+ * Immutable value object representing consistent options.
39
+ *
40
+ * @since 1.3.2
41
+ * @internal
42
+ */
43
+ struct built : public common_options<node_ids_options>::built {
44
+ };
45
+
46
+ /**
47
+ * Validates options and returns them as an immutable value.
48
+ *
49
+ * @return consistent options as an immutable value
50
+ *
51
+ * @since 1.3.2
52
+ * @internal
53
+ */
54
+ [[nodiscard]] auto build() const -> built
55
+ {
56
+ return { build_common_options() };
57
+ }
58
+ };
59
+
60
+ using node_ids_handler = std::function<void(error, std::vector<node_id>)>;
61
+
62
+ } // namespace couchbase
@@ -18,6 +18,9 @@
18
18
  #pragma once
19
19
 
20
20
  #include <couchbase/cas.hxx>
21
+ #include <couchbase/node_id.hxx>
22
+
23
+ #include <utility>
21
24
 
22
25
  namespace couchbase
23
26
  {
@@ -48,6 +51,19 @@ public:
48
51
  {
49
52
  }
50
53
 
54
+ /**
55
+ * @param cas
56
+ * @param node_id identity of the node that served the request
57
+ *
58
+ * @since 1.3.2
59
+ * @uncommitted
60
+ */
61
+ result(couchbase::cas cas, couchbase::node_id node_id)
62
+ : cas_(cas)
63
+ , node_id_(std::move(node_id))
64
+ {
65
+ }
66
+
51
67
  /**
52
68
  * @return
53
69
  *
@@ -59,8 +75,34 @@ public:
59
75
  return cas_;
60
76
  }
61
77
 
78
+ /**
79
+ * Returns the identity of the cluster node that served this request.
80
+ *
81
+ * The returned node_id is default-constructed (falsy) when the node
82
+ * could not be determined.
83
+ *
84
+ * @return identity of the serving node
85
+ *
86
+ * @since 1.3.2
87
+ * @uncommitted
88
+ */
89
+ [[nodiscard]] auto node_id() const -> const couchbase::node_id&
90
+ {
91
+ return node_id_;
92
+ }
93
+
94
+ /**
95
+ * @since 1.3.2
96
+ * @internal
97
+ */
98
+ void node_id(couchbase::node_id id)
99
+ {
100
+ node_id_ = std::move(id);
101
+ }
102
+
62
103
  private:
63
104
  couchbase::cas cas_{ 0U };
105
+ couchbase::node_id node_id_{};
64
106
  };
65
107
 
66
108
  } // namespace couchbase
package/dist/binding.d.ts CHANGED
@@ -2854,6 +2854,7 @@ export interface CppConnection extends CppConnectionAutogen {
2854
2854
  report_id?: string;
2855
2855
  bucket_name?: string;
2856
2856
  services?: CppServiceType[];
2857
+ timeout?: number;
2857
2858
  }, callback: (err: CppError | null, result: {
2858
2859
  version: number;
2859
2860
  id: string;
package/dist/bucket.d.ts CHANGED
@@ -2,7 +2,7 @@ import { CppConnection } from './binding';
2
2
  import { Cluster } from './cluster';
3
3
  import { Collection } from './collection';
4
4
  import { CollectionManager } from './collectionmanager';
5
- import { PingOptions, PingResult } from './diagnosticstypes';
5
+ import { PingOptions, PingResult, WaitUntilReadyOptions } from './diagnosticstypes';
6
6
  import { Scope } from './scope';
7
7
  import { StreamableRowPromise } from './streamablepromises';
8
8
  import { Transcoder } from './transcoders';
@@ -96,4 +96,12 @@ export declare class Bucket {
96
96
  * @param callback A node-style callback to be invoked after execution.
97
97
  */
98
98
  ping(options?: PingOptions, callback?: NodeCallback<PingResult>): Promise<PingResult>;
99
+ /**
100
+ * Waits until the bucket reaches the desired state or the timeout elapses.
101
+ *
102
+ * @param timeout The time in milliseconds to wait for the bucket to become ready.
103
+ * @param options Optional parameters.
104
+ * @param callback A callback to be invoked after execution.
105
+ */
106
+ waitUntilReady(timeout: number, options?: WaitUntilReadyOptions, callback?: NodeCallback<void>): Promise<void>;
99
107
  }
package/dist/bucket.js CHANGED
@@ -4,6 +4,7 @@ exports.Bucket = void 0;
4
4
  const collection_1 = require("./collection");
5
5
  const collectionmanager_1 = require("./collectionmanager");
6
6
  const diagnosticsexecutor_1 = require("./diagnosticsexecutor");
7
+ const waituntilreadyexecutor_1 = require("./waituntilreadyexecutor");
7
8
  const scope_1 = require("./scope");
8
9
  const utilities_1 = require("./utilities");
9
10
  const viewexecutor_1 = require("./viewexecutor");
@@ -142,5 +143,25 @@ class Bucket {
142
143
  bucket: this.name,
143
144
  }), callback);
144
145
  }
146
+ /**
147
+ * Waits until the bucket reaches the desired state or the timeout elapses.
148
+ *
149
+ * @param timeout The time in milliseconds to wait for the bucket to become ready.
150
+ * @param options Optional parameters.
151
+ * @param callback A callback to be invoked after execution.
152
+ */
153
+ waitUntilReady(timeout, options, callback) {
154
+ if (options instanceof Function) {
155
+ callback = arguments[1];
156
+ options = undefined;
157
+ }
158
+ if (!options) {
159
+ options = {};
160
+ }
161
+ const exec = new waituntilreadyexecutor_1.WaitUntilReadyExecutor(this._cluster, this.name);
162
+ const timeout_ = timeout;
163
+ const options_ = options;
164
+ return utilities_1.PromiseHelper.wrapAsync(() => exec.waitUntilReady(timeout_, options_), callback);
165
+ }
145
166
  }
146
167
  exports.Bucket = Bucket;
package/dist/cluster.d.ts CHANGED
@@ -5,7 +5,7 @@ import { Authenticator } from './authenticators';
5
5
  import { CppConnection } from './binding';
6
6
  import { Bucket } from './bucket';
7
7
  import { BucketManager } from './bucketmanager';
8
- import { DiagnosticsOptions, DiagnosticsResult, PingOptions, PingResult } from './diagnosticstypes';
8
+ import { DiagnosticsOptions, DiagnosticsResult, PingOptions, PingResult, WaitUntilReadyOptions } from './diagnosticstypes';
9
9
  import { EventingFunctionManager } from './eventingfunctionmanager';
10
10
  import { CouchbaseLogger, Logger } from './logger';
11
11
  import { Meter } from './metrics';
@@ -521,6 +521,15 @@ export declare class Cluster {
521
521
  * @param callback A node-style callback to be invoked after execution.
522
522
  */
523
523
  ping(options?: PingOptions, callback?: NodeCallback<PingResult>): Promise<PingResult>;
524
+ /**
525
+ * Waits until the cluster reaches the desired state or the timeout elapses.
526
+ * The default desired state is ClusterState.Online.
527
+ *
528
+ * @param timeout The time in milliseconds to wait for the cluster to become ready.
529
+ * @param options Optional parameters for this operation.
530
+ * @param callback A callback to be invoked after execution.
531
+ */
532
+ waitUntilReady(timeout: number, options?: WaitUntilReadyOptions, callback?: NodeCallback<void>): Promise<void>;
524
533
  /**
525
534
  * Shuts down this cluster object. Cleaning up all resources associated with it.
526
535
  *
package/dist/cluster.js CHANGED
@@ -13,6 +13,7 @@ const bucketmanager_1 = require("./bucketmanager");
13
13
  const configProfile_1 = require("./configProfile");
14
14
  const connspec_1 = require("./connspec");
15
15
  const diagnosticsexecutor_1 = require("./diagnosticsexecutor");
16
+ const waituntilreadyexecutor_1 = require("./waituntilreadyexecutor");
16
17
  const eventingfunctionmanager_1 = require("./eventingfunctionmanager");
17
18
  const logger_1 = require("./logger");
18
19
  const loggingmeter_1 = require("./loggingmeter");
@@ -487,6 +488,27 @@ class Cluster {
487
488
  const options_ = options;
488
489
  return utilities_1.PromiseHelper.wrapAsync(() => exec.ping(options_), callback);
489
490
  }
491
+ /**
492
+ * Waits until the cluster reaches the desired state or the timeout elapses.
493
+ * The default desired state is ClusterState.Online.
494
+ *
495
+ * @param timeout The time in milliseconds to wait for the cluster to become ready.
496
+ * @param options Optional parameters for this operation.
497
+ * @param callback A callback to be invoked after execution.
498
+ */
499
+ waitUntilReady(timeout, options, callback) {
500
+ if (options instanceof Function) {
501
+ callback = arguments[1];
502
+ options = undefined;
503
+ }
504
+ if (!options) {
505
+ options = {};
506
+ }
507
+ const exec = new waituntilreadyexecutor_1.WaitUntilReadyExecutor(this);
508
+ const timeout_ = timeout;
509
+ const options_ = options;
510
+ return utilities_1.PromiseHelper.wrapAsync(() => exec.waitUntilReady(timeout_, options_), callback);
511
+ }
490
512
  /**
491
513
  * Shuts down this cluster object. Cleaning up all resources associated with it.
492
514
  *
@@ -8,7 +8,7 @@ import { CouchbaseList, CouchbaseMap, CouchbaseQueue, CouchbaseSet } from './dat
8
8
  import { DurabilityLevel, ReadPreference, StoreSemantics } from './generaltypes';
9
9
  import { MutationState } from './mutationstate';
10
10
  import { ObservableRequestHandler } from './observabilityhandler';
11
- import { ObservabilityInstruments } from './observabilitytypes';
11
+ import { KeyValueOp, ObservabilityInstruments } from './observabilitytypes';
12
12
  import { CollectionQueryIndexManager } from './queryindexmanager';
13
13
  import { RangeScan, SamplingScan, PrefixScan } from './rangeScan';
14
14
  import { Scope } from './scope';
@@ -578,7 +578,7 @@ export declare class Collection {
578
578
  /**
579
579
  * @internal
580
580
  */
581
- _getReplica(key: string, obsReqHandler: ObservableRequestHandler, options: {
581
+ _getReplica(key: string, opType: KeyValueOp, obsReqHandler: ObservableRequestHandler | null, options: {
582
582
  transcoder?: Transcoder;
583
583
  timeout?: number;
584
584
  readPreference?: ReadPreference;
@@ -718,7 +718,7 @@ export declare class Collection {
718
718
  /**
719
719
  * @internal
720
720
  */
721
- _lookupInReplica(key: string, obsReqHandler: ObservableRequestHandler, specs: LookupInSpec[], options: {
721
+ _lookupInReplica(key: string, opType: KeyValueOp, obsReqHandler: ObservableRequestHandler | null, specs: LookupInSpec[], options: {
722
722
  timeout?: number;
723
723
  readPreference?: ReadPreference;
724
724
  parentSpan?: RequestSpan;