couchbase 4.2.9 → 4.2.10
Sign up to get free protection for your applications and to get access to all the features.
- package/deps/couchbase-cxx-client/CMakeLists.txt +4 -0
- package/deps/couchbase-cxx-client/cmake/CompilerWarnings.cmake +7 -3
- package/deps/couchbase-cxx-client/cmake/OpenSSL.cmake +1 -0
- package/deps/couchbase-cxx-client/core/bucket.cxx +52 -2
- package/deps/couchbase-cxx-client/core/bucket.hxx +1 -1
- package/deps/couchbase-cxx-client/core/cluster.cxx +38 -0
- package/deps/couchbase-cxx-client/core/impl/bucket.cxx +24 -0
- package/deps/couchbase-cxx-client/core/impl/cluster.cxx +73 -0
- package/deps/couchbase-cxx-client/core/impl/diagnostics.cxx +294 -0
- package/deps/couchbase-cxx-client/core/impl/diagnostics.hxx +39 -0
- package/deps/couchbase-cxx-client/core/impl/scope.cxx +19 -4
- package/deps/couchbase-cxx-client/core/impl/search.cxx +75 -2
- package/deps/couchbase-cxx-client/core/impl/search.hxx +8 -0
- package/deps/couchbase-cxx-client/core/impl/search_index_manager.cxx +261 -18
- package/deps/couchbase-cxx-client/core/impl/search_request.cxx +139 -0
- package/deps/couchbase-cxx-client/core/impl/vector_query.cxx +42 -0
- package/deps/couchbase-cxx-client/core/impl/vector_search.cxx +40 -0
- package/deps/couchbase-cxx-client/core/io/http_session.hxx +6 -3
- package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +24 -32
- package/deps/couchbase-cxx-client/core/io/mcbp_session.hxx +1 -0
- package/deps/couchbase-cxx-client/core/logger/logger.cxx +1 -1
- package/deps/couchbase-cxx-client/core/meta/features.hxx +10 -0
- package/deps/couchbase-cxx-client/core/operations/document_query.cxx +6 -1
- package/deps/couchbase-cxx-client/core/operations/document_search.cxx +37 -1
- package/deps/couchbase-cxx-client/core/operations/document_search.hxx +11 -0
- package/deps/couchbase-cxx-client/core/operations/management/collection_create.cxx +7 -6
- package/deps/couchbase-cxx-client/core/operations/management/collection_create.hxx +1 -1
- package/deps/couchbase-cxx-client/core/operations/management/collection_update.cxx +7 -8
- package/deps/couchbase-cxx-client/core/operations/management/collection_update.hxx +1 -1
- package/deps/couchbase-cxx-client/core/operations/management/error_utils.cxx +3 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_analyze_document.cxx +17 -1
- package/deps/couchbase-cxx-client/core/operations/management/search_index_analyze_document.hxx +3 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_control_ingest.cxx +21 -1
- package/deps/couchbase-cxx-client/core/operations/management/search_index_control_ingest.hxx +3 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_control_plan_freeze.cxx +21 -1
- package/deps/couchbase-cxx-client/core/operations/management/search_index_control_plan_freeze.hxx +3 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_control_query.cxx +21 -1
- package/deps/couchbase-cxx-client/core/operations/management/search_index_control_query.hxx +3 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_drop.cxx +17 -1
- package/deps/couchbase-cxx-client/core/operations/management/search_index_drop.hxx +3 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_get.cxx +17 -1
- package/deps/couchbase-cxx-client/core/operations/management/search_index_get.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.cxx +39 -22
- package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.hxx +3 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_get_documents_count.cxx +18 -1
- package/deps/couchbase-cxx-client/core/operations/management/search_index_get_documents_count.hxx +3 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_upsert.cxx +17 -1
- package/deps/couchbase-cxx-client/core/operations/management/search_index_upsert.hxx +3 -0
- package/deps/couchbase-cxx-client/core/topology/collections_manifest.hxx +1 -1
- package/deps/couchbase-cxx-client/core/topology/collections_manifest_json.hxx +1 -1
- package/deps/couchbase-cxx-client/core/transactions/internal/utils.hxx +4 -0
- package/deps/couchbase-cxx-client/core/vector_query_combination.hxx +23 -0
- package/deps/couchbase-cxx-client/couchbase/bucket.hxx +29 -0
- package/deps/couchbase-cxx-client/couchbase/cluster.hxx +110 -0
- package/deps/couchbase-cxx-client/couchbase/codec/json_transcoder.hxx +1 -1
- package/deps/couchbase-cxx-client/couchbase/codec/raw_binary_transcoder.hxx +2 -1
- package/deps/couchbase-cxx-client/couchbase/codec/raw_json_transcoder.hxx +78 -0
- package/deps/couchbase-cxx-client/couchbase/codec/raw_string_transcoder.hxx +72 -0
- package/deps/couchbase-cxx-client/couchbase/create_collection_options.hxx +29 -1
- package/deps/couchbase-cxx-client/couchbase/diagnostics_options.hxx +75 -0
- package/deps/couchbase-cxx-client/couchbase/diagnostics_result.hxx +124 -0
- package/deps/couchbase-cxx-client/couchbase/endpoint_diagnostics.hxx +206 -0
- package/deps/couchbase-cxx-client/couchbase/endpoint_ping_report.hxx +205 -0
- package/deps/couchbase-cxx-client/couchbase/get_options.hxx +1 -6
- package/deps/couchbase-cxx-client/couchbase/management/collection_spec.hxx +1 -1
- package/deps/couchbase-cxx-client/couchbase/ping_options.hxx +93 -0
- package/deps/couchbase-cxx-client/couchbase/ping_result.hxx +118 -0
- package/deps/couchbase-cxx-client/couchbase/scope.hxx +24 -8
- package/deps/couchbase-cxx-client/couchbase/scope_search_index_manager.hxx +291 -0
- package/deps/couchbase-cxx-client/couchbase/search_request.hxx +120 -0
- package/deps/couchbase-cxx-client/couchbase/service_type.hxx +58 -0
- package/deps/couchbase-cxx-client/couchbase/update_collection_options.hxx +32 -3
- package/deps/couchbase-cxx-client/couchbase/vector_query.hxx +99 -0
- package/deps/couchbase-cxx-client/couchbase/vector_search.hxx +85 -0
- package/deps/couchbase-cxx-client/couchbase/vector_search_options.hxx +76 -0
- package/dist/binding.d.ts +9 -0
- package/dist/binding.js +4 -1
- package/dist/bindingutilities.d.ts +6 -1
- package/dist/bindingutilities.js +15 -1
- package/dist/cluster.d.ts +12 -1
- package/dist/cluster.js +22 -0
- package/dist/couchbase.d.ts +1 -0
- package/dist/couchbase.js +1 -0
- package/dist/searchexecutor.d.ts +2 -2
- package/dist/searchexecutor.js +19 -3
- package/dist/searchtypes.d.ts +46 -0
- package/dist/searchtypes.js +81 -1
- package/dist/vectorsearch.d.ts +99 -0
- package/dist/vectorsearch.js +132 -0
- package/package.json +7 -7
- package/src/constants.cpp +11 -0
- package/src/jstocbpp_autogen.hpp +24 -7
- package/tools/gen-bindings-json.py +2 -0
@@ -22,11 +22,14 @@
|
|
22
22
|
#include <couchbase/bucket.hxx>
|
23
23
|
#include <couchbase/bucket_manager.hxx>
|
24
24
|
#include <couchbase/cluster_options.hxx>
|
25
|
+
#include <couchbase/diagnostics_options.hxx>
|
26
|
+
#include <couchbase/ping_options.hxx>
|
25
27
|
#include <couchbase/query_index_manager.hxx>
|
26
28
|
#include <couchbase/query_options.hxx>
|
27
29
|
#include <couchbase/search_index_manager.hxx>
|
28
30
|
#include <couchbase/search_options.hxx>
|
29
31
|
#include <couchbase/search_query.hxx>
|
32
|
+
#include <couchbase/search_request.hxx>
|
30
33
|
#include <couchbase/transactions.hxx>
|
31
34
|
|
32
35
|
#include <memory>
|
@@ -141,6 +144,9 @@ class cluster
|
|
141
144
|
/**
|
142
145
|
* Performs a query against the full text search services.
|
143
146
|
*
|
147
|
+
* Consider using the newer @ref cluster::search() interface instead, which can be used
|
148
|
+
* for both traditional FTS queries, and to perform a @ref vector_search
|
149
|
+
*
|
144
150
|
* @param index_name name of the search index
|
145
151
|
* @param query query object, see hierarchy of @ref search_query for more details.
|
146
152
|
* @param options options to customize the query request.
|
@@ -159,6 +165,9 @@ class cluster
|
|
159
165
|
/**
|
160
166
|
* Performs a query against the full text search services.
|
161
167
|
*
|
168
|
+
* Consider using the newer @ref cluster::search() interface instead, which can be used
|
169
|
+
* for both traditional FTS queries, and to perform a vector search.
|
170
|
+
*
|
162
171
|
* @param index_name name of the search index
|
163
172
|
* @param query query object, see hierarchy of @ref search_query for more details.
|
164
173
|
* @param options options to customize the query request.
|
@@ -175,6 +184,47 @@ class cluster
|
|
175
184
|
[[nodiscard]] auto search_query(std::string index_name, const class search_query& query, const search_options& options = {}) const
|
176
185
|
-> std::future<std::pair<search_error_context, search_result>>;
|
177
186
|
|
187
|
+
/**
|
188
|
+
* Performs a request against the full text search services.
|
189
|
+
*
|
190
|
+
* This can be used to perform a traditional FTS query, and/or a vector search.
|
191
|
+
*
|
192
|
+
* @param index_name name of the search index
|
193
|
+
* @param request request object, see @ref search_request for more details.
|
194
|
+
* @param options options to customize the query request.
|
195
|
+
* @param handler the handler that implements @ref search_handler
|
196
|
+
*
|
197
|
+
* @exception errc::common::ambiguous_timeout
|
198
|
+
* @exception errc::common::unambiguous_timeout
|
199
|
+
*
|
200
|
+
* @see https://docs.couchbase.com/server/current/fts/fts-introduction.html
|
201
|
+
*
|
202
|
+
* @since 1.0.0
|
203
|
+
* @volatile
|
204
|
+
*/
|
205
|
+
void search(std::string index_name, search_request request, const search_options& options, search_handler&& handler) const;
|
206
|
+
|
207
|
+
/**
|
208
|
+
* Performs a request against the full text search services.
|
209
|
+
*
|
210
|
+
* This can be used to perform a traditional FTS query, and/or a vector search.
|
211
|
+
*
|
212
|
+
* @param index_name name of the search index
|
213
|
+
* @param request request object, see @ref search_request for more details.
|
214
|
+
* @param options options to customize the query request.
|
215
|
+
* @return future object that carries result of the operation
|
216
|
+
*
|
217
|
+
* @exception errc::common::ambiguous_timeout
|
218
|
+
* @exception errc::common::unambiguous_timeout
|
219
|
+
*
|
220
|
+
* @see https://docs.couchbase.com/server/current/fts/fts-introduction.html
|
221
|
+
*
|
222
|
+
* @since 1.0.0
|
223
|
+
* @volatile
|
224
|
+
*/
|
225
|
+
[[nodiscard]] auto search(std::string index_name, search_request request, const search_options& = {}) const
|
226
|
+
-> std::future<std::pair<search_error_context, search_result>>;
|
227
|
+
|
178
228
|
/**
|
179
229
|
* Performs a query against the analytics services.
|
180
230
|
*
|
@@ -207,6 +257,66 @@ class cluster
|
|
207
257
|
[[nodiscard]] auto analytics_query(std::string statement, const analytics_options& options = {}) const
|
208
258
|
-> std::future<std::pair<analytics_error_context, analytics_result>>;
|
209
259
|
|
260
|
+
/**
|
261
|
+
* Performs application-level ping requests against services in the Couchbase cluster.
|
262
|
+
*
|
263
|
+
* @note This operation performs active I/O against services and endpoints to assess their health. If you do not
|
264
|
+
* wish to performs I/O, consider using @ref diagnostics() instead.
|
265
|
+
*
|
266
|
+
* @param options custom options to change the default behavior.
|
267
|
+
* @param handler the handler that implements @ref ping_handler.
|
268
|
+
*
|
269
|
+
* @since 1.0.0
|
270
|
+
* @committed
|
271
|
+
*/
|
272
|
+
void ping(const ping_options& options, ping_handler&& handler) const;
|
273
|
+
|
274
|
+
/**
|
275
|
+
* Performs application-level ping requests against services in the Couchbase cluster.
|
276
|
+
*
|
277
|
+
* @note This operation performs active I/O against services and endpoints to assess their health. If you do not
|
278
|
+
* wish to performs I/O, consider using @ref diagnostics() instead.
|
279
|
+
*
|
280
|
+
* @param options custom options to change the default behavior.
|
281
|
+
* @return future object that carries result of the operation.
|
282
|
+
*
|
283
|
+
* @since 1.0.0
|
284
|
+
* @committed
|
285
|
+
*/
|
286
|
+
[[nodiscard]] auto ping(const ping_options& options = {}) const -> std::future<ping_result>;
|
287
|
+
|
288
|
+
/**
|
289
|
+
* Assembles a diagnostics report on the current state of the cluster from the SDK's point of view.
|
290
|
+
*
|
291
|
+
* @note This operation does not perform any I/O to produce the report. It will only use the current known state of
|
292
|
+
* the cluster to assemble the report So, if for example, no SQL++ queries have been run, the Query service's socket
|
293
|
+
* pool might be empty and as a result not show up in the report. If you wish to actively assess the health of the
|
294
|
+
* cluster by performing I/O, consider using @ref ping() instead.
|
295
|
+
*
|
296
|
+
* @param options custom options to change the default behavior.
|
297
|
+
* @param handler the handler that implements @ref diagnostics_handler.
|
298
|
+
*
|
299
|
+
* @since 1.0.0
|
300
|
+
* @committed
|
301
|
+
*/
|
302
|
+
void diagnostics(const diagnostics_options& options, diagnostics_handler&& handler) const;
|
303
|
+
|
304
|
+
/**
|
305
|
+
* Assembles a diagnostics report on the current state of the cluster from the SDK's point of view.
|
306
|
+
*
|
307
|
+
* @note This operation does not perform any I/O to produce the report. It will only use the current known state of
|
308
|
+
* the cluster to assemble the report So, if for example, no SQL++ queries have been run, the Query service's socket
|
309
|
+
* pool might be empty and as a result not show up in the report. If you wish to actively assess the health of the
|
310
|
+
* cluster by performing I/O, consider using @ref ping() instead.
|
311
|
+
*
|
312
|
+
* @param options custom options to change the default behavior.
|
313
|
+
* @return future object that carries result of the operation.
|
314
|
+
*
|
315
|
+
* @since 1.0.0
|
316
|
+
* @committed
|
317
|
+
*/
|
318
|
+
[[nodiscard]] auto diagnostics(const diagnostics_options& options = {}) const -> std::future<diagnostics_result>;
|
319
|
+
|
210
320
|
/**
|
211
321
|
* Provides access to the N1QL index management services.
|
212
322
|
*
|
@@ -40,7 +40,7 @@ class json_transcoder
|
|
40
40
|
{
|
41
41
|
if (encoded.flags != 0 && !codec_flags::has_common_flags(encoded.flags, codec_flags::json_common_flags)) {
|
42
42
|
throw std::system_error(errc::common::decoding_failure,
|
43
|
-
"json_transcoder
|
43
|
+
"json_transcoder expects document to have JSON common flags, flags=" + std::to_string(encoded.flags));
|
44
44
|
}
|
45
45
|
|
46
46
|
return Serializer::template deserialize<Document>(encoded.data);
|
@@ -21,6 +21,7 @@
|
|
21
21
|
#include <couchbase/codec/encoded_value.hxx>
|
22
22
|
#include <couchbase/codec/transcoder_traits.hxx>
|
23
23
|
#include <couchbase/error_codes.hxx>
|
24
|
+
|
24
25
|
#include <type_traits>
|
25
26
|
|
26
27
|
namespace couchbase::codec
|
@@ -40,7 +41,7 @@ class raw_binary_transcoder
|
|
40
41
|
{
|
41
42
|
if (!codec_flags::has_common_flags(encoded.flags, codec_flags::binary_common_flags)) {
|
42
43
|
throw std::system_error(errc::common::decoding_failure,
|
43
|
-
"raw_binary_transcoder
|
44
|
+
"raw_binary_transcoder expects document to have BINARY common flags, flags=" +
|
44
45
|
std::to_string(encoded.flags));
|
45
46
|
}
|
46
47
|
|
@@ -0,0 +1,78 @@
|
|
1
|
+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright 2024. 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/codec_flags.hxx>
|
21
|
+
#include <couchbase/codec/encoded_value.hxx>
|
22
|
+
#include <couchbase/codec/transcoder_traits.hxx>
|
23
|
+
#include <couchbase/error_codes.hxx>
|
24
|
+
|
25
|
+
#include <cstddef>
|
26
|
+
#include <string>
|
27
|
+
#include <string_view>
|
28
|
+
#include <type_traits>
|
29
|
+
#include <vector>
|
30
|
+
|
31
|
+
namespace couchbase
|
32
|
+
{
|
33
|
+
#ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
|
34
|
+
namespace core::utils
|
35
|
+
{
|
36
|
+
std::vector<std::byte>
|
37
|
+
to_binary(std::string_view value) noexcept;
|
38
|
+
} // namespace core::utils
|
39
|
+
#endif
|
40
|
+
|
41
|
+
namespace codec
|
42
|
+
{
|
43
|
+
class raw_json_transcoder
|
44
|
+
{
|
45
|
+
public:
|
46
|
+
template<typename Document, std::enable_if_t<std::is_same_v<Document, std::string> || std::is_same_v<Document, binary>, bool> = true>
|
47
|
+
static auto encode(const Document& document) -> encoded_value
|
48
|
+
{
|
49
|
+
if constexpr (std::is_same_v<Document, std::string>) {
|
50
|
+
return { core::utils::to_binary(document), codec_flags::json_common_flags };
|
51
|
+
} else {
|
52
|
+
return { std::move(document), codec_flags::json_common_flags };
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
template<typename Document, std::enable_if_t<std::is_same_v<Document, std::string> || std::is_same_v<Document, binary>, bool> = true>
|
57
|
+
static auto decode(const encoded_value& encoded) -> Document
|
58
|
+
{
|
59
|
+
if (!codec_flags::has_common_flags(encoded.flags, codec_flags::json_common_flags)) {
|
60
|
+
throw std::system_error(errc::common::decoding_failure,
|
61
|
+
"raw_json_transcoder expects document to have JSON common flags, flags=" +
|
62
|
+
std::to_string(encoded.flags));
|
63
|
+
}
|
64
|
+
if constexpr (std::is_same_v<Document, std::string>) {
|
65
|
+
return std::string{ reinterpret_cast<const char*>(encoded.data.data()), encoded.data.size() };
|
66
|
+
} else {
|
67
|
+
return encoded.data;
|
68
|
+
}
|
69
|
+
}
|
70
|
+
};
|
71
|
+
|
72
|
+
#ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
|
73
|
+
template<>
|
74
|
+
struct is_transcoder<raw_json_transcoder> : public std::true_type {
|
75
|
+
};
|
76
|
+
#endif
|
77
|
+
} // namespace codec
|
78
|
+
} // namespace couchbase
|
@@ -0,0 +1,72 @@
|
|
1
|
+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright 2024. 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/codec_flags.hxx>
|
21
|
+
#include <couchbase/codec/encoded_value.hxx>
|
22
|
+
#include <couchbase/codec/transcoder_traits.hxx>
|
23
|
+
#include <couchbase/error_codes.hxx>
|
24
|
+
|
25
|
+
#include <cstddef>
|
26
|
+
#include <string>
|
27
|
+
#include <string_view>
|
28
|
+
#include <type_traits>
|
29
|
+
#include <vector>
|
30
|
+
|
31
|
+
namespace couchbase
|
32
|
+
{
|
33
|
+
#ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
|
34
|
+
namespace core::utils
|
35
|
+
{
|
36
|
+
std::vector<std::byte>
|
37
|
+
to_binary(std::string_view value) noexcept;
|
38
|
+
} // namespace core::utils
|
39
|
+
#endif
|
40
|
+
|
41
|
+
namespace codec
|
42
|
+
{
|
43
|
+
class raw_string_transcoder
|
44
|
+
{
|
45
|
+
public:
|
46
|
+
using document_type = std::string;
|
47
|
+
|
48
|
+
static auto encode(document_type document) -> encoded_value
|
49
|
+
{
|
50
|
+
return { core::utils::to_binary(document), codec_flags::string_common_flags };
|
51
|
+
}
|
52
|
+
|
53
|
+
template<typename Document = document_type, std::enable_if_t<std::is_same_v<Document, document_type>, bool> = true>
|
54
|
+
static auto decode(const encoded_value& encoded) -> Document
|
55
|
+
{
|
56
|
+
if (!codec_flags::has_common_flags(encoded.flags, codec_flags::string_common_flags)) {
|
57
|
+
throw std::system_error(errc::common::decoding_failure,
|
58
|
+
"raw_string_transcoder expects document to have STRING common flags, flags=" +
|
59
|
+
std::to_string(encoded.flags));
|
60
|
+
}
|
61
|
+
|
62
|
+
return std::string{ reinterpret_cast<const char*>(encoded.data.data()), encoded.data.size() };
|
63
|
+
}
|
64
|
+
};
|
65
|
+
|
66
|
+
#ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
|
67
|
+
template<>
|
68
|
+
struct is_transcoder<raw_string_transcoder> : public std::true_type {
|
69
|
+
};
|
70
|
+
#endif
|
71
|
+
} // namespace codec
|
72
|
+
} // namespace couchbase
|
@@ -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
|
-
|
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
|