couchbase 4.2.9 → 4.2.11-rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. package/deps/couchbase-cxx-client/CMakeLists.txt +4 -0
  2. package/deps/couchbase-cxx-client/cmake/CompilerWarnings.cmake +7 -3
  3. package/deps/couchbase-cxx-client/cmake/OpenSSL.cmake +1 -0
  4. package/deps/couchbase-cxx-client/core/bucket.cxx +67 -2
  5. package/deps/couchbase-cxx-client/core/bucket.hxx +2 -1
  6. package/deps/couchbase-cxx-client/core/cluster.cxx +65 -1
  7. package/deps/couchbase-cxx-client/core/impl/bucket.cxx +24 -0
  8. package/deps/couchbase-cxx-client/core/impl/cluster.cxx +73 -0
  9. package/deps/couchbase-cxx-client/core/impl/collection.cxx +2 -2
  10. package/deps/couchbase-cxx-client/core/impl/diagnostics.cxx +294 -0
  11. package/deps/couchbase-cxx-client/core/impl/diagnostics.hxx +39 -0
  12. package/deps/couchbase-cxx-client/core/impl/query_index_manager.cxx +6 -6
  13. package/deps/couchbase-cxx-client/core/impl/scope.cxx +19 -4
  14. package/deps/couchbase-cxx-client/core/impl/search.cxx +75 -2
  15. package/deps/couchbase-cxx-client/core/impl/search.hxx +8 -0
  16. package/deps/couchbase-cxx-client/core/impl/search_index_manager.cxx +261 -18
  17. package/deps/couchbase-cxx-client/core/impl/search_request.cxx +139 -0
  18. package/deps/couchbase-cxx-client/core/impl/vector_query.cxx +42 -0
  19. package/deps/couchbase-cxx-client/core/impl/vector_search.cxx +40 -0
  20. package/deps/couchbase-cxx-client/core/io/http_session.hxx +6 -3
  21. package/deps/couchbase-cxx-client/core/io/http_session_manager.hxx +7 -1
  22. package/deps/couchbase-cxx-client/core/io/mcbp_command.hxx +10 -0
  23. package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +48 -33
  24. package/deps/couchbase-cxx-client/core/io/mcbp_session.hxx +2 -0
  25. package/deps/couchbase-cxx-client/core/logger/logger.cxx +1 -1
  26. package/deps/couchbase-cxx-client/core/management/design_document.hxx +1 -1
  27. package/deps/couchbase-cxx-client/core/meta/features.hxx +26 -1
  28. package/deps/couchbase-cxx-client/core/operations/document_lookup_in_all_replicas.hxx +1 -1
  29. package/deps/couchbase-cxx-client/core/operations/document_lookup_in_any_replica.hxx +1 -1
  30. package/deps/couchbase-cxx-client/core/operations/document_query.cxx +8 -3
  31. package/deps/couchbase-cxx-client/core/operations/document_search.cxx +37 -1
  32. package/deps/couchbase-cxx-client/core/operations/document_search.hxx +11 -0
  33. package/deps/couchbase-cxx-client/core/operations/document_view.cxx +3 -0
  34. package/deps/couchbase-cxx-client/core/operations/document_view.hxx +1 -0
  35. package/deps/couchbase-cxx-client/core/operations/management/collection_create.cxx +7 -6
  36. package/deps/couchbase-cxx-client/core/operations/management/collection_create.hxx +1 -1
  37. package/deps/couchbase-cxx-client/core/operations/management/collection_update.cxx +7 -8
  38. package/deps/couchbase-cxx-client/core/operations/management/collection_update.hxx +1 -1
  39. package/deps/couchbase-cxx-client/core/operations/management/error_utils.cxx +3 -0
  40. package/deps/couchbase-cxx-client/core/operations/management/query_index_create.cxx +24 -13
  41. package/deps/couchbase-cxx-client/core/operations/management/query_index_create.hxx +1 -1
  42. package/deps/couchbase-cxx-client/core/operations/management/search_index_analyze_document.cxx +17 -1
  43. package/deps/couchbase-cxx-client/core/operations/management/search_index_analyze_document.hxx +3 -0
  44. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_ingest.cxx +21 -1
  45. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_ingest.hxx +3 -0
  46. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_plan_freeze.cxx +21 -1
  47. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_plan_freeze.hxx +3 -0
  48. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_query.cxx +21 -1
  49. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_query.hxx +3 -0
  50. package/deps/couchbase-cxx-client/core/operations/management/search_index_drop.cxx +17 -1
  51. package/deps/couchbase-cxx-client/core/operations/management/search_index_drop.hxx +3 -0
  52. package/deps/couchbase-cxx-client/core/operations/management/search_index_get.cxx +17 -1
  53. package/deps/couchbase-cxx-client/core/operations/management/search_index_get.hxx +2 -0
  54. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.cxx +39 -22
  55. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.hxx +3 -0
  56. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_documents_count.cxx +18 -1
  57. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_documents_count.hxx +3 -0
  58. package/deps/couchbase-cxx-client/core/operations/management/search_index_upsert.cxx +17 -1
  59. package/deps/couchbase-cxx-client/core/operations/management/search_index_upsert.hxx +3 -0
  60. package/deps/couchbase-cxx-client/core/origin.cxx +14 -0
  61. package/deps/couchbase-cxx-client/core/origin.hxx +6 -0
  62. package/deps/couchbase-cxx-client/core/protocol/status.cxx +2 -0
  63. package/deps/couchbase-cxx-client/core/protocol/status.hxx +1 -0
  64. package/deps/couchbase-cxx-client/core/topology/capabilities.hxx +70 -1
  65. package/deps/couchbase-cxx-client/core/topology/capabilities_fmt.hxx +30 -2
  66. package/deps/couchbase-cxx-client/core/topology/collections_manifest.hxx +1 -1
  67. package/deps/couchbase-cxx-client/core/topology/collections_manifest_json.hxx +1 -1
  68. package/deps/couchbase-cxx-client/core/topology/configuration.hxx +1 -34
  69. package/deps/couchbase-cxx-client/core/topology/configuration_fmt.hxx +2 -2
  70. package/deps/couchbase-cxx-client/core/topology/configuration_json.hxx +43 -20
  71. package/deps/couchbase-cxx-client/core/transactions/internal/exceptions_internal.hxx +5 -0
  72. package/deps/couchbase-cxx-client/core/transactions/internal/utils.hxx +4 -0
  73. package/deps/couchbase-cxx-client/core/vector_query_combination.hxx +23 -0
  74. package/deps/couchbase-cxx-client/couchbase/bucket.hxx +29 -0
  75. package/deps/couchbase-cxx-client/couchbase/cluster.hxx +110 -0
  76. package/deps/couchbase-cxx-client/couchbase/codec/json_transcoder.hxx +1 -1
  77. package/deps/couchbase-cxx-client/couchbase/codec/raw_binary_transcoder.hxx +2 -1
  78. package/deps/couchbase-cxx-client/couchbase/codec/raw_json_transcoder.hxx +78 -0
  79. package/deps/couchbase-cxx-client/couchbase/codec/raw_string_transcoder.hxx +72 -0
  80. package/deps/couchbase-cxx-client/couchbase/collection_query_index_manager.hxx +80 -11
  81. package/deps/couchbase-cxx-client/couchbase/create_collection_options.hxx +29 -1
  82. package/deps/couchbase-cxx-client/couchbase/diagnostics_options.hxx +75 -0
  83. package/deps/couchbase-cxx-client/couchbase/diagnostics_result.hxx +124 -0
  84. package/deps/couchbase-cxx-client/couchbase/endpoint_diagnostics.hxx +206 -0
  85. package/deps/couchbase-cxx-client/couchbase/endpoint_ping_report.hxx +205 -0
  86. package/deps/couchbase-cxx-client/couchbase/fmt/key_value_status_code.hxx +3 -1
  87. package/deps/couchbase-cxx-client/couchbase/get_options.hxx +1 -6
  88. package/deps/couchbase-cxx-client/couchbase/key_value_status_code.hxx +1 -0
  89. package/deps/couchbase-cxx-client/couchbase/management/collection_spec.hxx +1 -1
  90. package/deps/couchbase-cxx-client/couchbase/ping_options.hxx +93 -0
  91. package/deps/couchbase-cxx-client/couchbase/ping_result.hxx +118 -0
  92. package/deps/couchbase-cxx-client/couchbase/query_index_manager.hxx +6 -8
  93. package/deps/couchbase-cxx-client/couchbase/scope.hxx +24 -8
  94. package/deps/couchbase-cxx-client/couchbase/scope_search_index_manager.hxx +291 -0
  95. package/deps/couchbase-cxx-client/couchbase/search_request.hxx +120 -0
  96. package/deps/couchbase-cxx-client/couchbase/service_type.hxx +58 -0
  97. package/deps/couchbase-cxx-client/couchbase/update_collection_options.hxx +32 -3
  98. package/deps/couchbase-cxx-client/couchbase/vector_query.hxx +99 -0
  99. package/deps/couchbase-cxx-client/couchbase/vector_search.hxx +85 -0
  100. package/deps/couchbase-cxx-client/couchbase/vector_search_options.hxx +76 -0
  101. package/dist/binding.d.ts +33 -2
  102. package/dist/binding.js +4 -1
  103. package/dist/bindingutilities.d.ts +16 -3
  104. package/dist/bindingutilities.js +47 -7
  105. package/dist/cluster.d.ts +12 -1
  106. package/dist/cluster.js +22 -0
  107. package/dist/couchbase.d.ts +2 -0
  108. package/dist/couchbase.js +2 -0
  109. package/dist/queryindexmanager.d.ts +4 -4
  110. package/dist/queryindexmanager.js +7 -7
  111. package/dist/scope.d.ts +21 -0
  112. package/dist/scope.js +34 -0
  113. package/dist/scopesearchindexmanager.d.ts +116 -0
  114. package/dist/scopesearchindexmanager.js +406 -0
  115. package/dist/sdspecs.js +10 -9
  116. package/dist/sdutils.d.ts +1 -0
  117. package/dist/sdutils.js +4 -0
  118. package/dist/searchexecutor.d.ts +5 -3
  119. package/dist/searchexecutor.js +27 -4
  120. package/dist/searchindexmanager.d.ts +58 -3
  121. package/dist/searchindexmanager.js +188 -104
  122. package/dist/searchtypes.d.ts +46 -0
  123. package/dist/searchtypes.js +81 -1
  124. package/dist/vectorsearch.d.ts +99 -0
  125. package/dist/vectorsearch.js +132 -0
  126. package/dist/viewexecutor.js +13 -9
  127. package/dist/viewindexmanager.d.ts +70 -7
  128. package/dist/viewindexmanager.js +236 -103
  129. package/dist/viewtypes.d.ts +26 -0
  130. package/dist/viewtypes.js +17 -1
  131. package/package.json +7 -7
  132. package/src/constants.cpp +12 -0
  133. package/src/jstocbpp_autogen.hpp +113 -13
  134. package/tools/gen-bindings-json.py +2 -0
@@ -53,8 +53,7 @@ class collection_query_index_manager
53
53
  {
54
54
  public:
55
55
  /**
56
- * Get all indexes within a collection.
57
- *
56
+ * Get all indexes within the collection.
58
57
  *
59
58
  * @param options optional parameters
60
59
  * @param handler the handler that implements @ref get_all_query_indexes_handler
@@ -64,13 +63,23 @@ class collection_query_index_manager
64
63
  */
65
64
  void get_all_indexes(const get_all_query_indexes_options& options, get_all_query_indexes_handler&& handler) const;
66
65
 
66
+ /**
67
+ * Get all indexes within the collection..
68
+ *
69
+ * @param options optional parameters
70
+ * @return future object that carries result of the operation
71
+ *
72
+ * @since 1.0.0
73
+ * @committed
74
+ */
67
75
  [[nodiscard]] auto get_all_indexes(const get_all_query_indexes_options& options) const
68
76
  -> std::future<std::pair<manager_error_context, std::vector<couchbase::management::query_index>>>;
77
+
69
78
  /**
70
79
  * Create an index on the collection.
71
80
  *
72
81
  * @param index_name name of the index
73
- * @param fields the fields to create the index over
82
+ * @param keys the keys to create the index over
74
83
  * @param options optional parameters
75
84
  * @param handler the handler that implements @ref create_query_index_handler
76
85
  *
@@ -78,16 +87,26 @@ class collection_query_index_manager
78
87
  * @committed
79
88
  */
80
89
  void create_index(std::string index_name,
81
- std::vector<std::string> fields,
90
+ std::vector<std::string> keys,
82
91
  const create_query_index_options& options,
83
92
  create_query_index_handler&& handler) const;
84
93
 
85
- [[nodiscard]] auto create_index(std::string index_name,
86
- std::vector<std::string> fields,
87
- const create_query_index_options& options) const -> std::future<manager_error_context>;
94
+ /**
95
+ * Create an index on the collection.
96
+ *
97
+ * @param index_name name of the index
98
+ * @param keys the keys to create the index over
99
+ * @param options optional parameters
100
+ * @return future object that carries result of the operation
101
+ *
102
+ * @since 1.0.0
103
+ * @committed
104
+ */
105
+ [[nodiscard]] auto create_index(std::string index_name, std::vector<std::string> keys, const create_query_index_options& options) const
106
+ -> std::future<manager_error_context>;
88
107
 
89
108
  /**
90
- * Create a primary index on a collection.
109
+ * Create a primary index on the collection.
91
110
  *
92
111
  * @param options optional parameters
93
112
  * @param handler the handler that implements @ref create_query_index_handler
@@ -97,10 +116,19 @@ class collection_query_index_manager
97
116
  */
98
117
  void create_primary_index(const create_primary_query_index_options& options, create_query_index_handler&& handler) const;
99
118
 
119
+ /**
120
+ * Create a primary index on the collection.
121
+ *
122
+ * @param options optional parameters
123
+ * @return future object that carries result of the operation
124
+ *
125
+ * @since 1.0.0
126
+ * @committed
127
+ */
100
128
  [[nodiscard]] auto create_primary_index(const create_primary_query_index_options& options) const -> std::future<manager_error_context>;
101
129
 
102
130
  /**
103
- * Drop primary index on a collection.
131
+ * Drop primary index on the collection.
104
132
  *
105
133
  * @param options optional parameters
106
134
  * @param handler the handler that implements @ref drop_query_index_handler
@@ -110,10 +138,19 @@ class collection_query_index_manager
110
138
  */
111
139
  void drop_primary_index(const drop_primary_query_index_options& options, drop_query_index_handler&& handler) const;
112
140
 
141
+ /**
142
+ * Drop primary index on the collection.
143
+ *
144
+ * @param options optional parameters
145
+ * @return future object that carries result of the operation
146
+ *
147
+ * @since 1.0.0
148
+ * @committed
149
+ */
113
150
  [[nodiscard]] auto drop_primary_index(const drop_primary_query_index_options& options) const -> std::future<manager_error_context>;
114
151
 
115
152
  /**
116
- * Drop index in collection.
153
+ * Drop specified query index in the collection.
117
154
  *
118
155
  * @param index_name name of the index to drop
119
156
  * @param options optional parameters
@@ -124,14 +161,25 @@ class collection_query_index_manager
124
161
  */
125
162
  void drop_index(std::string index_name, const drop_query_index_options& options, drop_query_index_handler&& handler) const;
126
163
 
164
+ /**
165
+ * Drop specified query index in the collection.
166
+ *
167
+ * @param index_name name of the index to drop
168
+ * @param options optional parameters
169
+ * @return future object that carries result of the operation
170
+ *
171
+ * @since 1.0.0
172
+ * @committed
173
+ */
127
174
  [[nodiscard]] auto drop_index(std::string index_name, const drop_query_index_options& options) const
128
175
  -> std::future<manager_error_context>;
176
+
129
177
  /**
130
178
  * Builds all currently deferred indexes in this collection.
131
179
  *
132
180
  * By default, this method will build the indexes on the collection.
133
181
  *
134
- * @param options the custom options
182
+ * @param options optional parameters
135
183
  * @param handler the handler that implements @ref build_deferred_query_indexes_handler
136
184
  *
137
185
  * @since 1.0.0
@@ -139,6 +187,17 @@ class collection_query_index_manager
139
187
  */
140
188
  void build_deferred_indexes(const build_query_index_options& options, build_deferred_query_indexes_handler&& handler) const;
141
189
 
190
+ /**
191
+ * Builds all currently deferred indexes in this collection.
192
+ *
193
+ * By default, this method will build the indexes on the collection.
194
+ *
195
+ * @param options optional parameters
196
+ * @return future object that carries result of the operation
197
+ *
198
+ * @since 1.0.0
199
+ * @committed
200
+ */
142
201
  [[nodiscard]] auto build_deferred_indexes(const build_query_index_options& options) const -> std::future<manager_error_context>;
143
202
 
144
203
  /**
@@ -155,6 +214,16 @@ class collection_query_index_manager
155
214
  const watch_query_indexes_options& options,
156
215
  watch_query_indexes_handler&& handler) const;
157
216
 
217
+ /**
218
+ * Polls the state of a set of indexes, until they all are online.
219
+ *
220
+ * @param index_names names of the indexes to watch
221
+ * @param options optional parameters
222
+ * @return future object that carries result of the operation
223
+ *
224
+ * @since 1.0.0
225
+ * @committed
226
+ */
158
227
  [[nodiscard]] auto watch_indexes(std::vector<std::string> index_names, const watch_query_indexes_options& options) const
159
228
  -> std::future<manager_error_context>;
160
229
 
@@ -20,6 +20,7 @@
20
20
  #include <couchbase/common_options.hxx>
21
21
  #include <couchbase/manager_error_context.hxx>
22
22
 
23
+ #include <cstdint>
23
24
  #include <functional>
24
25
  #include <optional>
25
26
 
@@ -27,17 +28,44 @@ namespace couchbase
27
28
  {
28
29
  struct create_collection_options : public common_options<create_collection_options> {
29
30
  public:
31
+ /**
32
+ * Immutable value object representing consistent options.
33
+ *
34
+ * @since 1.0.0
35
+ * @internal
36
+ */
30
37
  struct built : public common_options<create_collection_options>::built {
31
38
  };
32
39
 
40
+ /**
41
+ * Validates the options and returns them as an immutable value.
42
+ *
43
+ * @return consistent options as an immutable value
44
+ *
45
+ * @exception std::system_error with code errc::common::invalid_argument if the options are not valid
46
+ *
47
+ * @since 1.0.0
48
+ * @internal
49
+ */
33
50
  [[nodiscard]] auto build() const -> built
34
51
  {
35
52
  return { build_common_options() };
36
53
  }
37
54
  };
38
55
 
56
+ /**
57
+ * The settings to use when creating the collection
58
+ */
39
59
  struct create_collection_settings {
40
- std::uint32_t max_expiry{ 0 };
60
+ /**
61
+ * The maximum expiry, in seconds, for documents in this collection. Values greater than or equal to -1 are valid.
62
+ * Value of 0 sets max_expiry to the bucket-level setting and value of -1 to set it as no-expiry.
63
+ */
64
+ std::int32_t max_expiry{ 0 };
65
+
66
+ /**
67
+ * Whether history retention should be enabled. If unset, the bucket-level setting is used.
68
+ */
41
69
  std::optional<bool> history{};
42
70
  };
43
71
 
@@ -0,0 +1,75 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2023-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/diagnostics_result.hxx>
22
+
23
+ #include <optional>
24
+ #include <utility>
25
+
26
+ namespace couchbase
27
+ {
28
+ struct diagnostics_options : public common_options<diagnostics_options> {
29
+ /**
30
+ * Sets a custom report ID that will be used in the report. If no report ID is provided, the client will generate a
31
+ * unique one.
32
+ *
33
+ * @param report_id the report ID that should be used.
34
+ * @return reference to this object, for use in chaining.
35
+ *
36
+ * @since 1.0.0
37
+ * @committed
38
+ */
39
+ auto report_id(std::string report_id) -> diagnostics_options&
40
+ {
41
+ report_id_ = std::move(report_id);
42
+ return self();
43
+ }
44
+
45
+ /**
46
+ * Immutable value object representing consistent options.
47
+ *
48
+ * @since 1.0.0
49
+ * @internal
50
+ */
51
+ struct built : public common_options<diagnostics_options>::built {
52
+ std::optional<std::string> report_id;
53
+ };
54
+
55
+ /**
56
+ * Validates the options and returns them as an immutable value.
57
+ *
58
+ * @return consistent options as an immutable value
59
+ *
60
+ * @exception std::system_error with code errc::common::invalid_argument if the options are not valid
61
+ *
62
+ * @since 1.0.0
63
+ * @internal
64
+ */
65
+ [[nodiscard]] auto build() const -> built
66
+ {
67
+ return { build_common_options(), report_id_ };
68
+ }
69
+
70
+ private:
71
+ std::optional<std::string> report_id_{};
72
+ };
73
+
74
+ using diagnostics_handler = std::function<void(diagnostics_result)>;
75
+ } // namespace couchbase
@@ -0,0 +1,124 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2023-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/codec/tao_json_serializer.hxx>
21
+ #include <couchbase/endpoint_diagnostics.hxx>
22
+ #include <couchbase/service_type.hxx>
23
+
24
+ #include <cstdint>
25
+ #include <map>
26
+ #include <string>
27
+ #include <utility>
28
+ #include <vector>
29
+
30
+ namespace couchbase
31
+ {
32
+ class diagnostics_result
33
+ {
34
+ public:
35
+ /**
36
+ * @since 1.0.0
37
+ * @internal
38
+ */
39
+ diagnostics_result() = default;
40
+
41
+ /**
42
+ * @since 1.0.0
43
+ * @internal
44
+ */
45
+ diagnostics_result(std::string id,
46
+ std::uint16_t version,
47
+ std::string sdk,
48
+ std::map<service_type, std::vector<endpoint_diagnostics>> endpoints)
49
+ : id_{ std::move(id) }
50
+ , version_{ version }
51
+ , sdk_{ std::move(sdk) }
52
+ , endpoints_{ std::move(endpoints) }
53
+ {
54
+ }
55
+
56
+ /**
57
+ * Returns the ID of this report.
58
+ *
59
+ * @return the report ID.
60
+ *
61
+ * @since 1.0.0
62
+ * @committed
63
+ */
64
+ [[nodiscard]] auto id() const -> std::string
65
+ {
66
+ return id_;
67
+ }
68
+
69
+ /**
70
+ * Returns the version of this report (useful when exporting to JSON).
71
+ *
72
+ * @return the report version
73
+ *
74
+ * @since 1.0.0
75
+ * @committed
76
+ */
77
+ [[nodiscard]] auto version() const -> std::uint16_t
78
+ {
79
+ return version_;
80
+ }
81
+
82
+ /**
83
+ * Returns the identifier of this SDK (useful when exporting to JSON).
84
+ *
85
+ * @return the SDK identifier.
86
+ *
87
+ * @since 1.0.0
88
+ * @committed
89
+ */
90
+ [[nodiscard]] auto sdk() const -> std::string
91
+ {
92
+ return sdk_;
93
+ }
94
+
95
+ /**
96
+ * Returns the diagnostics for each individual endpoint, organised by service type.
97
+ *
98
+ * @return the service type to endpoint diagnostics reports map.
99
+ *
100
+ * @since 1.0.0
101
+ * @committed
102
+ */
103
+ [[nodiscard]] auto endpoints() const -> std::map<service_type, std::vector<endpoint_diagnostics>>
104
+ {
105
+ return endpoints_;
106
+ }
107
+
108
+ /**
109
+ * Exports the diagnostics report as JSON.
110
+ *
111
+ * @return the JSON report.
112
+ *
113
+ * @since 1.0.0
114
+ * @committed
115
+ */
116
+ [[nodiscard]] auto as_json() const -> codec::tao_json_serializer::document_type;
117
+
118
+ private:
119
+ std::string id_{};
120
+ std::uint16_t version_{};
121
+ std::string sdk_{};
122
+ std::map<service_type, std::vector<endpoint_diagnostics>> endpoints_{};
123
+ };
124
+ } // namespace couchbase
@@ -0,0 +1,206 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2023-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/service_type.hxx>
21
+
22
+ #include <chrono>
23
+ #include <optional>
24
+ #include <string>
25
+ #include <utility>
26
+
27
+ namespace couchbase
28
+ {
29
+ enum class endpoint_state {
30
+ /**
31
+ * The endpoint is connected and ready.
32
+ *
33
+ * @since 1.0.0
34
+ * @committed
35
+ */
36
+ connected,
37
+
38
+ /**
39
+ * The endpoint is disconnected but trying to connect right now.
40
+ *
41
+ * @since 1.0.0
42
+ * @committed
43
+ */
44
+ connecting,
45
+
46
+ /**
47
+ * The endpoint is disconnected (not reachable) and not trying to connect.
48
+ *
49
+ * @since 1.0.0
50
+ * @committed
51
+ */
52
+ disconnected,
53
+
54
+ /**
55
+ * The endpoint is currently disconnecting.
56
+ *
57
+ * @since 1.0.0
58
+ * @committed
59
+ */
60
+ disconnecting,
61
+ };
62
+
63
+ class endpoint_diagnostics
64
+ {
65
+ public:
66
+ endpoint_diagnostics() = default;
67
+
68
+ /**
69
+ * @since 1.0.0
70
+ * @internal
71
+ */
72
+ endpoint_diagnostics(service_type type,
73
+ std::string id,
74
+ std::optional<std::chrono::microseconds> last_activity,
75
+ std::string local,
76
+ std::string remote,
77
+ std::optional<std::string> endpoint_namespace,
78
+ endpoint_state state,
79
+ std::optional<std::string> details)
80
+ : type_{ type }
81
+ , id_{ std::move(id) }
82
+ , last_activity_{ last_activity }
83
+ , local_{ std::move(local) }
84
+ , remote_{ std::move(remote) }
85
+ , namespace_{ std::move(endpoint_namespace) }
86
+ , state_{ state }
87
+ , details_{ std::move(details) }
88
+ {
89
+ }
90
+
91
+ /**
92
+ * Returns the service type for this endpoint.
93
+ *
94
+ * @return the service type.
95
+ *
96
+ * @since 1.0.0
97
+ * @committed
98
+ */
99
+ [[nodiscard]] auto type() const -> service_type
100
+ {
101
+ return type_;
102
+ }
103
+
104
+ /**
105
+ *
106
+ * Returns the ID for this endpoint.
107
+ *
108
+ * @return the endpoint ID.
109
+ *
110
+ * @since 1.0.0
111
+ * @committed
112
+ */
113
+ [[nodiscard]] auto id() const -> std::string
114
+ {
115
+ return id_;
116
+ }
117
+
118
+ /**
119
+ * Returns the time since the last activity, if there has been one.
120
+ *
121
+ * @return the duration since the last activity.
122
+ *
123
+ * @since 1.0.0
124
+ * @committed
125
+ */
126
+ [[nodiscard]] auto last_activity() const -> std::optional<std::chrono::microseconds>
127
+ {
128
+ return last_activity_;
129
+ }
130
+
131
+ /**
132
+ * Returns the local socket address for this endpoint.
133
+ *
134
+ * @return the local socket address.
135
+ *
136
+ * @since 1.0.0
137
+ * @committed
138
+ */
139
+ [[nodiscard]] auto local() const -> std::string
140
+ {
141
+ return local_;
142
+ }
143
+
144
+ /**
145
+ * Returns the remote socket address for this endpoint.
146
+ *
147
+ * @return the remote socket address.
148
+ *
149
+ * @since 1.0.0
150
+ * @committed
151
+ */
152
+ [[nodiscard]] auto remote() const -> std::string
153
+ {
154
+ return remote_;
155
+ }
156
+
157
+ /**
158
+ * Returns the namespace of this endpoint (likely the bucket name if present).
159
+ *
160
+ * @return the namespace.
161
+ *
162
+ * @since 1.0.0
163
+ * @committed
164
+ */
165
+ [[nodiscard]] auto endpoint_namespace() const -> std::optional<std::string>
166
+ {
167
+ return namespace_;
168
+ }
169
+
170
+ /**
171
+ * Returns the current state of the endpoint.
172
+ *
173
+ * @return the endpoint state.
174
+ *
175
+ * @since 1.0.0
176
+ * @committed
177
+ */
178
+ [[nodiscard]] auto state() const -> endpoint_state
179
+ {
180
+ return state_;
181
+ }
182
+
183
+ /**
184
+ * Returns any additional details about the endpoint, if available.
185
+ *
186
+ * @return endpoint details.
187
+ *
188
+ * @since 1.0.0
189
+ * @committed
190
+ */
191
+ [[nodiscard]] auto details() const -> std::optional<std::string>
192
+ {
193
+ return details_;
194
+ }
195
+
196
+ private:
197
+ service_type type_{};
198
+ std::string id_{};
199
+ std::optional<std::chrono::microseconds> last_activity_{};
200
+ std::string local_{};
201
+ std::string remote_{};
202
+ std::optional<std::string> namespace_{};
203
+ endpoint_state state_{};
204
+ std::optional<std::string> details_{};
205
+ };
206
+ } // namespace couchbase