couchbase 4.2.1 → 4.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. package/CMakeLists.txt +1 -0
  2. package/deps/couchbase-cxx-client/.gitmodules +3 -0
  3. package/deps/couchbase-cxx-client/.idea/misc.xml +1 -0
  4. package/deps/couchbase-cxx-client/.idea/vcs.xml +1 -0
  5. package/deps/couchbase-cxx-client/CMakeLists.txt +11 -1
  6. package/deps/couchbase-cxx-client/README.md +3 -3
  7. package/deps/couchbase-cxx-client/cmake/CompilerWarnings.cmake +4 -1
  8. package/deps/couchbase-cxx-client/cmake/VersionInfo.cmake +13 -1
  9. package/deps/couchbase-cxx-client/cmake/build_version.hxx.in +1 -0
  10. package/deps/couchbase-cxx-client/core/cluster.hxx +15 -5
  11. package/deps/couchbase-cxx-client/core/impl/build_deferred_query_indexes.cxx +17 -6
  12. package/deps/couchbase-cxx-client/core/impl/cluster.cxx +1 -1
  13. package/deps/couchbase-cxx-client/core/impl/collection_query_index_manager.cxx +93 -0
  14. package/deps/couchbase-cxx-client/core/impl/configuration_profiles_registry.cxx +11 -0
  15. package/deps/couchbase-cxx-client/core/impl/create_query_index.cxx +119 -0
  16. package/deps/couchbase-cxx-client/core/impl/drop_query_index.cxx +108 -0
  17. package/deps/couchbase-cxx-client/core/impl/get.cxx +1 -1
  18. package/deps/couchbase-cxx-client/core/impl/get_all_query_indexes.cxx +76 -0
  19. package/deps/couchbase-cxx-client/core/impl/query.cxx +5 -7
  20. package/deps/couchbase-cxx-client/core/impl/watch_query_indexes.cxx +168 -0
  21. package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +15 -1
  22. package/deps/couchbase-cxx-client/core/logger/configuration.hxx +3 -0
  23. package/deps/couchbase-cxx-client/core/logger/level.hxx +21 -0
  24. package/deps/couchbase-cxx-client/core/logger/logger.hxx +4 -6
  25. package/deps/couchbase-cxx-client/core/meta/CMakeLists.txt +4 -2
  26. package/deps/couchbase-cxx-client/core/meta/features.hxx +31 -0
  27. package/deps/couchbase-cxx-client/core/meta/version.cxx +67 -5
  28. package/deps/couchbase-cxx-client/core/meta/version.hxx +12 -1
  29. package/deps/couchbase-cxx-client/core/metrics/CMakeLists.txt +4 -1
  30. package/deps/couchbase-cxx-client/core/metrics/logging_meter.cxx +46 -5
  31. package/deps/couchbase-cxx-client/core/metrics/logging_meter.hxx +10 -26
  32. package/deps/couchbase-cxx-client/core/operations/document_get_projected.cxx +3 -2
  33. package/deps/couchbase-cxx-client/core/operations/document_query.cxx +10 -12
  34. package/deps/couchbase-cxx-client/core/operations/document_query.hxx +1 -3
  35. package/deps/couchbase-cxx-client/core/operations/management/query_index_build.cxx +8 -14
  36. package/deps/couchbase-cxx-client/core/operations/management/query_index_build.hxx +2 -1
  37. package/deps/couchbase-cxx-client/core/operations/management/query_index_build_deferred.hxx +15 -8
  38. package/deps/couchbase-cxx-client/core/operations/management/query_index_create.cxx +7 -14
  39. package/deps/couchbase-cxx-client/core/operations/management/query_index_create.hxx +2 -0
  40. package/deps/couchbase-cxx-client/core/operations/management/query_index_drop.cxx +11 -16
  41. package/deps/couchbase-cxx-client/core/operations/management/query_index_drop.hxx +2 -0
  42. package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all.cxx +8 -12
  43. package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all.hxx +4 -3
  44. package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all_deferred.cxx +21 -12
  45. package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all_deferred.hxx +3 -2
  46. package/deps/couchbase-cxx-client/core/origin.hxx +1 -1
  47. package/deps/couchbase-cxx-client/core/platform/uuid.cc +1 -2
  48. package/deps/couchbase-cxx-client/core/protocol/cmd_hello.hxx +5 -1
  49. package/deps/couchbase-cxx-client/core/query_context.hxx +79 -0
  50. package/deps/couchbase-cxx-client/core/tracing/CMakeLists.txt +3 -1
  51. package/deps/couchbase-cxx-client/core/tracing/threshold_logging_tracer.cxx +19 -4
  52. package/deps/couchbase-cxx-client/core/tracing/threshold_logging_tracer.hxx +2 -2
  53. package/deps/couchbase-cxx-client/core/transactions/async_attempt_context.hxx +10 -4
  54. package/deps/couchbase-cxx-client/core/transactions/atr_cleanup_entry.cxx +52 -63
  55. package/deps/couchbase-cxx-client/core/transactions/attempt_context.hxx +8 -3
  56. package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.cxx +163 -126
  57. package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.hxx +24 -37
  58. package/deps/couchbase-cxx-client/core/transactions/forward_compat.hxx +4 -4
  59. package/deps/couchbase-cxx-client/core/transactions/internal/atr_cleanup_entry.hxx +51 -13
  60. package/deps/couchbase-cxx-client/core/transactions/internal/client_record.hxx +26 -1
  61. package/deps/couchbase-cxx-client/core/transactions/internal/doc_record.hxx +21 -0
  62. package/deps/couchbase-cxx-client/core/transactions/internal/logging.hxx +40 -18
  63. package/deps/couchbase-cxx-client/core/transactions/internal/transaction_context.hxx +5 -0
  64. package/deps/couchbase-cxx-client/core/transactions/result.hxx +26 -0
  65. package/deps/couchbase-cxx-client/core/transactions/staged_mutation.cxx +48 -47
  66. package/deps/couchbase-cxx-client/core/transactions/staged_mutation.hxx +6 -6
  67. package/deps/couchbase-cxx-client/core/transactions/transaction_context.cxx +33 -19
  68. package/deps/couchbase-cxx-client/core/transactions/transaction_get_result.hxx +18 -2
  69. package/deps/couchbase-cxx-client/core/transactions/transaction_links.hxx +25 -2
  70. package/deps/couchbase-cxx-client/core/transactions/transactions.cxx +4 -4
  71. package/deps/couchbase-cxx-client/core/transactions/transactions_cleanup.cxx +49 -56
  72. package/deps/couchbase-cxx-client/core/transactions/waitable_op_list.hxx +7 -7
  73. package/deps/couchbase-cxx-client/core/transactions.hxx +0 -12
  74. package/deps/couchbase-cxx-client/core/utils/binary.hxx +1 -1
  75. package/deps/couchbase-cxx-client/core/utils/keyspace.hxx +55 -0
  76. package/deps/couchbase-cxx-client/couchbase/build_query_index_options.hxx +12 -45
  77. package/deps/couchbase-cxx-client/couchbase/cluster.hxx +1 -1
  78. package/deps/couchbase-cxx-client/couchbase/cluster_options.hxx +6 -7
  79. package/deps/couchbase-cxx-client/couchbase/collection.hxx +8 -0
  80. package/deps/couchbase-cxx-client/couchbase/collection_query_index_manager.hxx +218 -0
  81. package/deps/couchbase-cxx-client/couchbase/configuration_profiles_registry.hxx +3 -0
  82. package/deps/couchbase-cxx-client/couchbase/create_primary_query_index_options.hxx +166 -0
  83. package/deps/couchbase-cxx-client/couchbase/create_query_index_options.hxx +172 -0
  84. package/deps/couchbase-cxx-client/couchbase/drop_primary_query_index_options.hxx +129 -0
  85. package/deps/couchbase-cxx-client/couchbase/drop_query_index_options.hxx +116 -0
  86. package/deps/couchbase-cxx-client/couchbase/fmt/cas.hxx +1 -1
  87. package/deps/couchbase-cxx-client/couchbase/fmt/query_scan_consistency.hxx +46 -0
  88. package/deps/couchbase-cxx-client/couchbase/fmt/query_status.hxx +70 -0
  89. package/deps/couchbase-cxx-client/couchbase/fmt/tls_verify_mode.hxx +46 -0
  90. package/deps/couchbase-cxx-client/couchbase/get_all_query_indexes_options.hxx +100 -0
  91. package/deps/couchbase-cxx-client/{core → couchbase}/management/query_index.hxx +2 -2
  92. package/deps/couchbase-cxx-client/couchbase/metrics/meter.hxx +16 -0
  93. package/deps/couchbase-cxx-client/couchbase/query_index_manager.hxx +178 -6
  94. package/deps/couchbase-cxx-client/couchbase/query_options.hxx +1 -18
  95. package/deps/couchbase-cxx-client/couchbase/scope.hxx +5 -2
  96. package/deps/couchbase-cxx-client/couchbase/tracing/request_tracer.hxx +16 -0
  97. package/deps/couchbase-cxx-client/couchbase/transactions/async_attempt_context.hxx +11 -4
  98. package/deps/couchbase-cxx-client/couchbase/transactions/attempt_context.hxx +5 -3
  99. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_keyspace.hxx +16 -0
  100. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_query_options.hxx +0 -6
  101. package/deps/couchbase-cxx-client/couchbase/watch_query_indexes_options.hxx +115 -0
  102. package/deps/couchbase-cxx-client/examples/minimal.cxx +3 -1
  103. package/deps/couchbase-cxx-client/test/test_integration_crud.cxx +72 -0
  104. package/deps/couchbase-cxx-client/test/test_integration_management.cxx +727 -310
  105. package/deps/couchbase-cxx-client/test/test_integration_query.cxx +4 -8
  106. package/deps/couchbase-cxx-client/test/test_integration_transcoders.cxx +14 -0
  107. package/deps/couchbase-cxx-client/test/test_transaction_transaction_public_blocking_api.cxx +34 -19
  108. package/deps/couchbase-cxx-client/test/test_unit_transaction_logging.cxx +66 -22
  109. package/deps/couchbase-cxx-client/test/test_unit_utils.cxx +51 -0
  110. package/deps/couchbase-cxx-client/test/tools/tool_kv_loader.cxx +2 -2
  111. package/deps/couchbase-cxx-client/test/utils/integration_test_guard.cxx +2 -0
  112. package/deps/couchbase-cxx-client/test/utils/wait_until.cxx +4 -4
  113. package/deps/couchbase-cxx-client/third_party/docopt/.travis.yml +103 -0
  114. package/deps/couchbase-cxx-client/third_party/docopt/CMakeLists.txt +129 -0
  115. package/deps/couchbase-cxx-client/third_party/docopt/LICENSE-Boost-1.0 +23 -0
  116. package/deps/couchbase-cxx-client/third_party/docopt/LICENSE-MIT +23 -0
  117. package/deps/couchbase-cxx-client/third_party/docopt/README.rst +479 -0
  118. package/deps/couchbase-cxx-client/third_party/docopt/docopt-config.cmake +1 -0
  119. package/deps/couchbase-cxx-client/third_party/docopt/docopt.cpp +687 -0
  120. package/deps/couchbase-cxx-client/third_party/docopt/docopt.h +98 -0
  121. package/deps/couchbase-cxx-client/third_party/docopt/docopt.pc.in +9 -0
  122. package/deps/couchbase-cxx-client/third_party/docopt/docopt_private.h +676 -0
  123. package/deps/couchbase-cxx-client/third_party/docopt/docopt_util.h +122 -0
  124. package/deps/couchbase-cxx-client/third_party/docopt/docopt_value.h +341 -0
  125. package/deps/couchbase-cxx-client/third_party/docopt/examples/naval_fate.cpp +36 -0
  126. package/deps/couchbase-cxx-client/third_party/docopt/main.cpp +16 -0
  127. package/deps/couchbase-cxx-client/third_party/docopt/run_testcase.cpp +40 -0
  128. package/deps/couchbase-cxx-client/third_party/docopt/run_tests.py +72 -0
  129. package/deps/couchbase-cxx-client/third_party/docopt/testcases.docopt +957 -0
  130. package/deps/couchbase-cxx-client/tools/CMakeLists.txt +14 -0
  131. package/deps/couchbase-cxx-client/tools/cbc.cxx +65 -0
  132. package/deps/couchbase-cxx-client/tools/command.hxx +31 -0
  133. package/deps/couchbase-cxx-client/tools/command_registry.cxx +43 -0
  134. package/deps/couchbase-cxx-client/tools/command_registry.hxx +39 -0
  135. package/deps/couchbase-cxx-client/tools/get.cxx +267 -0
  136. package/deps/couchbase-cxx-client/tools/get.hxx +26 -0
  137. package/deps/couchbase-cxx-client/tools/query.cxx +441 -0
  138. package/deps/couchbase-cxx-client/tools/query.hxx +26 -0
  139. package/deps/couchbase-cxx-client/tools/utils.cxx +418 -0
  140. package/deps/couchbase-cxx-client/tools/utils.hxx +150 -0
  141. package/deps/couchbase-cxx-client/tools/version.cxx +82 -0
  142. package/deps/couchbase-cxx-client/tools/version.hxx +26 -0
  143. package/dist/authenticators.d.ts +2 -2
  144. package/dist/authenticators.js +1 -2
  145. package/dist/binding.d.ts +32 -16
  146. package/dist/cluster.js +14 -7
  147. package/dist/collection.d.ts +6 -0
  148. package/dist/collection.js +8 -0
  149. package/dist/queryexecutor.js +1 -1
  150. package/dist/queryindexmanager.d.ts +100 -4
  151. package/dist/queryindexmanager.js +344 -118
  152. package/dist/transactions.js +0 -2
  153. package/package.json +1 -1
  154. package/src/connection.cpp +2 -0
  155. package/src/connection.hpp +1 -0
  156. package/src/connection_autogen.cpp +16 -0
  157. package/src/jstocbpp_autogen.hpp +93 -23
  158. package/src/jstocbpp_basic.hpp +24 -0
  159. package/src/jstocbpp_transactions.hpp +0 -8
  160. package/tools/gen-bindings-js.js +1 -0
  161. package/tools/gen-bindings-json.py +4 -2
  162. package/deps/couchbase-cxx-client/core/transactions/logging.cxx +0 -107
@@ -0,0 +1,116 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2020-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_codes.hxx>
22
+ #include <couchbase/manager_error_context.hxx>
23
+
24
+ #include <optional>
25
+ #include <string>
26
+
27
+ namespace couchbase
28
+ {
29
+ class drop_query_index_options : public common_options<drop_query_index_options>
30
+ {
31
+ public:
32
+ /**
33
+ * Set flag to ignore error if the index already exists
34
+ *
35
+ * The default is to not ignore the error.
36
+ *
37
+ * @param ignore_if_exists if true, we don't return an error if the index already exists
38
+ * @return reference to this object, for use in chaining.
39
+ *
40
+ * @since 1.0.0
41
+ * @committed
42
+ */
43
+ auto ignore_if_not_exists(bool ignore_if_not_exists) -> drop_query_index_options&
44
+ {
45
+ ignore_if_not_exists_ = ignore_if_not_exists;
46
+ return self();
47
+ }
48
+ /**
49
+ * Immutable value object representing consistent options.
50
+ *
51
+ * @since 1.0.0
52
+ * @internal
53
+ */
54
+ struct built : public common_options<drop_query_index_options>::built {
55
+ bool ignore_if_not_exists{};
56
+ };
57
+
58
+ /**
59
+ * Validates options and returns them as an immutable value.
60
+ *
61
+ * @return consistent options as an immutable value
62
+ *
63
+ * @exception std::system_error with code errc::common::invalid_argument if the options are not valid
64
+ *
65
+ * @since 1.0.0
66
+ * @internal
67
+ */
68
+ [[nodiscard]] auto build() const -> built
69
+ {
70
+ return { build_common_options(), ignore_if_not_exists_ };
71
+ }
72
+
73
+ private:
74
+ bool ignore_if_not_exists_{ false };
75
+ };
76
+
77
+ /**
78
+ * The signature for the handler of the @ref query_index_manager#get_all_indexes() operation
79
+ *
80
+ * @since 1.0.0
81
+ * @uncommitted
82
+ */
83
+
84
+ using drop_query_index_handler = std::function<void(couchbase::manager_error_context)>;
85
+
86
+ #ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
87
+ namespace core
88
+ {
89
+ class cluster;
90
+ class query_context;
91
+ namespace impl
92
+ {
93
+
94
+ /**
95
+ * @since 1.0.0
96
+ * @internal
97
+ */
98
+ void
99
+ initiate_drop_query_index(std::shared_ptr<couchbase::core::cluster> core,
100
+ std::string bucket_name,
101
+ std::string index_name,
102
+ couchbase::drop_query_index_options::built options,
103
+ query_context query_ctx,
104
+ std::string collection_name,
105
+ drop_query_index_handler&& handler);
106
+ void
107
+ initiate_drop_query_index(std::shared_ptr<couchbase::core::cluster> core,
108
+ std::string bucket_name,
109
+ std::string index_name,
110
+ couchbase::drop_query_index_options::built options,
111
+ drop_query_index_handler&& handler);
112
+
113
+ #endif
114
+ } // namespace impl
115
+ } // namespace core
116
+ } // namespace couchbase
@@ -32,6 +32,6 @@ struct fmt::formatter<couchbase::cas> {
32
32
  template<typename FormatContext>
33
33
  auto format(const couchbase::cas& cas, FormatContext& ctx) const
34
34
  {
35
- return format_to(ctx.out(), "{:x}", cas.value());
35
+ return format_to(ctx.out(), "{:016x}", cas.value());
36
36
  }
37
37
  };
@@ -0,0 +1,46 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2020-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/query_scan_consistency.hxx>
21
+
22
+ #include <fmt/core.h>
23
+
24
+ template<>
25
+ struct fmt::formatter<couchbase::query_scan_consistency> {
26
+ template<typename ParseContext>
27
+ constexpr auto parse(ParseContext& ctx)
28
+ {
29
+ return ctx.begin();
30
+ }
31
+
32
+ template<typename FormatContext>
33
+ auto format(couchbase::query_scan_consistency mode, FormatContext& ctx) const
34
+ {
35
+ string_view name = "unknown";
36
+ switch (mode) {
37
+ case couchbase::query_scan_consistency::not_bounded:
38
+ name = "not_bounded";
39
+ break;
40
+ case couchbase::query_scan_consistency::request_plus:
41
+ name = "request_plus";
42
+ break;
43
+ }
44
+ return format_to(ctx.out(), "{}", name);
45
+ }
46
+ };
@@ -0,0 +1,70 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2020-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/query_status.hxx>
21
+
22
+ #include <fmt/core.h>
23
+
24
+ template<>
25
+ struct fmt::formatter<couchbase::query_status> {
26
+ template<typename ParseContext>
27
+ constexpr auto parse(ParseContext& ctx)
28
+ {
29
+ return ctx.begin();
30
+ }
31
+
32
+ template<typename FormatContext>
33
+ auto format(couchbase::query_status status, FormatContext& ctx) const
34
+ {
35
+ string_view name = "unknown";
36
+ switch (status) {
37
+ case couchbase::query_status::running:
38
+ name = "running";
39
+ break;
40
+ case couchbase::query_status::success:
41
+ name = "success";
42
+ break;
43
+ case couchbase::query_status::errors:
44
+ name = "errors";
45
+ break;
46
+ case couchbase::query_status::completed:
47
+ name = "completed";
48
+ break;
49
+ case couchbase::query_status::stopped:
50
+ name = "stopped";
51
+ break;
52
+ case couchbase::query_status::timeout:
53
+ name = "timeout";
54
+ break;
55
+ case couchbase::query_status::closed:
56
+ name = "closed";
57
+ break;
58
+ case couchbase::query_status::fatal:
59
+ name = "fatal";
60
+ break;
61
+ case couchbase::query_status::aborted:
62
+ name = "aborted";
63
+ break;
64
+ case couchbase::query_status::unknown:
65
+ name = "unknown";
66
+ break;
67
+ }
68
+ return format_to(ctx.out(), "{}", name);
69
+ }
70
+ };
@@ -0,0 +1,46 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2020-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/tls_verify_mode.hxx>
21
+
22
+ #include <fmt/core.h>
23
+
24
+ template<>
25
+ struct fmt::formatter<couchbase::tls_verify_mode> {
26
+ template<typename ParseContext>
27
+ constexpr auto parse(ParseContext& ctx)
28
+ {
29
+ return ctx.begin();
30
+ }
31
+
32
+ template<typename FormatContext>
33
+ auto format(couchbase::tls_verify_mode mode, FormatContext& ctx) const
34
+ {
35
+ string_view name = "unknown";
36
+ switch (mode) {
37
+ case couchbase::tls_verify_mode::none:
38
+ name = "none";
39
+ break;
40
+ case couchbase::tls_verify_mode::peer:
41
+ name = "peer";
42
+ break;
43
+ }
44
+ return format_to(ctx.out(), "{}", name);
45
+ }
46
+ };
@@ -0,0 +1,100 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2020-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_codes.hxx>
22
+ #include <couchbase/management/query_index.hxx>
23
+ #include <couchbase/manager_error_context.hxx>
24
+
25
+ #include <functional>
26
+ #include <memory>
27
+ #include <optional>
28
+ #include <string>
29
+
30
+ namespace couchbase
31
+ {
32
+ class get_all_query_indexes_options : public common_options<get_all_query_indexes_options>
33
+ {
34
+ public:
35
+ /**
36
+ * Immutable value object representing consistent options.
37
+ *
38
+ * @since 1.0.0
39
+ * @internal
40
+ */
41
+ struct built : public common_options<get_all_query_indexes_options>::built {
42
+ };
43
+
44
+ /**
45
+ * Validates options and returns them as an immutable value.
46
+ *
47
+ * @return consistent options as an immutable value
48
+ *
49
+ * @exception std::system_error with code errc::common::invalid_argument if the options are not valid
50
+ *
51
+ * @since 1.0.0
52
+ * @internal
53
+ */
54
+ [[nodiscard]] auto build() const -> built
55
+ {
56
+ return { build_common_options() };
57
+ }
58
+
59
+ private:
60
+ };
61
+
62
+ /**
63
+ * The signature for the handler of the @ref query_index_manager#get_all_indexes() operation
64
+ *
65
+ * @since 1.0.0
66
+ * @uncommitted
67
+ */
68
+
69
+ using get_all_indexes_handler = std::function<void(couchbase::manager_error_context, std::vector<couchbase::management::query::index>)>;
70
+
71
+ #ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
72
+ namespace core
73
+ {
74
+ class cluster;
75
+ class query_context;
76
+ namespace impl
77
+ {
78
+
79
+ /**
80
+ * @since 1.0.0
81
+ * @internal
82
+ */
83
+ void
84
+ initiate_get_all_query_indexes(std::shared_ptr<couchbase::core::cluster> core,
85
+ std::string bucket_name,
86
+ couchbase::get_all_query_indexes_options::built options,
87
+ get_all_indexes_handler&& handler);
88
+
89
+ void
90
+ initiate_get_all_query_indexes(std::shared_ptr<couchbase::core::cluster> core,
91
+ std::string bucket_name,
92
+ couchbase::get_all_query_indexes_options::built options,
93
+ query_context query_ctx,
94
+ std::string collection_name,
95
+ get_all_indexes_handler&& handler);
96
+
97
+ #endif
98
+ } // namespace impl
99
+ } // namespace core
100
+ } // namespace couchbase
@@ -21,7 +21,7 @@
21
21
  #include <string>
22
22
  #include <vector>
23
23
 
24
- namespace couchbase::core::management::query
24
+ namespace couchbase::management::query
25
25
  {
26
26
  struct index {
27
27
  bool is_primary{ false };
@@ -36,4 +36,4 @@ struct index {
36
36
  std::optional<std::string> collection_name{};
37
37
  };
38
38
 
39
- } // namespace couchbase::core::management::query
39
+ } // namespace couchbase::management::query
@@ -46,6 +46,22 @@ class meter
46
46
  meter& operator=(meter&& other) = default;
47
47
  virtual ~meter() = default;
48
48
 
49
+ /**
50
+ * SDK invokes this method when cluster is ready to emit metrics. Override it as NO-OP if no action is necessary.
51
+ */
52
+ virtual void start()
53
+ {
54
+ /* do nothing */
55
+ }
56
+
57
+ /**
58
+ * SDK invokes this method when cluster is closed. Override it as NO-OP if no action is necessary.
59
+ */
60
+ virtual void stop()
61
+ {
62
+ /* do nothing */
63
+ }
64
+
49
65
  virtual std::shared_ptr<value_recorder> get_value_recorder(const std::string& name, const std::map<std::string, std::string>& tags) = 0;
50
66
  };
51
67
 
@@ -18,6 +18,12 @@
18
18
  #pragma once
19
19
 
20
20
  #include <couchbase/build_query_index_options.hxx>
21
+ #include <couchbase/create_primary_query_index_options.hxx>
22
+ #include <couchbase/create_query_index_options.hxx>
23
+ #include <couchbase/drop_primary_query_index_options.hxx>
24
+ #include <couchbase/drop_query_index_options.hxx>
25
+ #include <couchbase/get_all_query_indexes_options.hxx>
26
+ #include <couchbase/watch_query_indexes_options.hxx>
21
27
 
22
28
  #include <future>
23
29
  #include <memory>
@@ -42,22 +48,158 @@ class cluster;
42
48
  class query_index_manager
43
49
  {
44
50
  public:
51
+ /**
52
+ * Get all indexes within a bucket.
53
+ *
54
+ *
55
+ * @param bucket_name specifies the bucket in which we look for the indexes
56
+ * @param options optional parameters
57
+ * @param handler the handler that implements @ref get_all_query_indexes_handler
58
+ *
59
+ * @since 1.0.0
60
+ * @committed
61
+ */
62
+ void get_all_indexes(std::string bucket_name, const get_all_query_indexes_options& options, get_all_indexes_handler&& handler) const
63
+ {
64
+ return core::impl::initiate_get_all_query_indexes(
65
+ core_, std::move(bucket_name), options.build(), std::forward<get_all_indexes_handler>(handler));
66
+ }
67
+ [[nodiscard]] auto get_all_indexes(std::string bucket_name, const get_all_query_indexes_options& options) const
68
+ -> std::future<std::pair<manager_error_context, std::vector<couchbase::management::query::index>>>
69
+ {
70
+ auto barrier = std::make_shared<std::promise<std::pair<manager_error_context, std::vector<couchbase::management::query::index>>>>();
71
+ auto future = barrier->get_future();
72
+ get_all_indexes(std::move(bucket_name), options, [barrier](auto ctx, auto resp) { barrier->set_value({ ctx, resp }); });
73
+ return future;
74
+ }
75
+ /**
76
+ * Create an index on a bucket.
77
+ *
78
+ * @param bucket_name specifies the bucket in which to create the index
79
+ * @param index_name name of the index
80
+ * @param fields the fields to create the index over
81
+ * @param options optional parameters
82
+ * @param handler the handler that implements @ref create_query_index_handler
83
+ *
84
+ * @since 1.0.0
85
+ * @committed
86
+ */
87
+ void create_index(std::string bucket_name,
88
+ std::string index_name,
89
+ std::vector<std::string> fields,
90
+ const create_query_index_options& options,
91
+ create_query_index_handler&& handler) const
92
+ {
93
+ core::impl::initiate_create_query_index(
94
+ core_, std::move(bucket_name), std::move(index_name), std::move(fields), options.build(), std::move(handler));
95
+ }
96
+
97
+ [[nodiscard]] auto create_index(std::string bucket_name,
98
+ std::string index_name,
99
+ std::vector<std::string> fields,
100
+ const create_query_index_options& options) const -> std::future<manager_error_context>
101
+ {
102
+ auto barrier = std::make_shared<std::promise<manager_error_context>>();
103
+ auto future = barrier->get_future();
104
+ create_index(
105
+ std::move(bucket_name), std::move(index_name), std::move(fields), options, [barrier](auto ctx) { barrier->set_value(ctx); });
106
+ return future;
107
+ }
108
+
109
+ /**
110
+ * Create a primary index on a bucket.
111
+ *
112
+ * @param bucket_name specifies the bucket in which to create the index
113
+ * @param options optional parameters
114
+ * @param handler the handler that implements @ref create_query_index_handler
115
+ *
116
+ * @since 1.0.0
117
+ * @committed
118
+ */
119
+ void create_primary_index(std::string bucket_name,
120
+ const create_primary_query_index_options& options,
121
+ create_query_index_handler&& handler)
122
+ {
123
+ return core::impl::initiate_create_primary_query_index(core_, std::move(bucket_name), options.build(), std::move(handler));
124
+ }
125
+
126
+ [[nodiscard]] auto create_primary_index(std::string bucket_name, const create_primary_query_index_options& options)
127
+ -> std::future<manager_error_context>
128
+ {
129
+ auto barrier = std::make_shared<std::promise<manager_error_context>>();
130
+ auto future = barrier->get_future();
131
+ create_primary_index(std::move(bucket_name), options, [barrier](auto ctx) { barrier->set_value(ctx); });
132
+ return future;
133
+ }
134
+ /**
135
+ * Drop primary index on a bucket.
136
+ *
137
+ * @param bucket_name name of the bucket in which to drop the primary index
138
+ * @param options optional parameters
139
+ * @param handler the handler that implements @ref drop_query_index_handler
140
+ *
141
+ * @since 1.0.0
142
+ * @committed
143
+ */
144
+ void drop_primary_index(std::string bucket_name, const drop_primary_query_index_options& options, drop_query_index_handler&& handler)
145
+ {
146
+ return core::impl::initiate_drop_primary_query_index(core_, std::move(bucket_name), options.build(), std::move(handler));
147
+ }
148
+
149
+ [[nodiscard]] auto drop_primary_index(std::string bucket_name, const drop_primary_query_index_options& options)
150
+ -> std::future<manager_error_context>
151
+ {
152
+ auto barrier = std::make_shared<std::promise<manager_error_context>>();
153
+ auto future = barrier->get_future();
154
+ drop_primary_index(std::move(bucket_name), options, [barrier](auto ctx) { barrier->set_value(ctx); });
155
+ return future;
156
+ }
157
+
158
+ /**
159
+ *
160
+ * @param bucket_name name of the bucket in which to drop the index
161
+ * @param index_name name of the index to drop
162
+ * @param options optional parameters
163
+ * @param handler handler that implements @ref drop_query_index_handler
164
+ *
165
+ * @since 1.0.0
166
+ * @committed
167
+ */
168
+ void drop_index(std::string bucket_name,
169
+ std::string index_name,
170
+ const drop_query_index_options& options,
171
+ drop_query_index_handler&& handler)
172
+ {
173
+ return core::impl::initiate_drop_query_index(
174
+ core_, std::move(bucket_name), std::move(index_name), options.build(), std::move(handler));
175
+ }
176
+
177
+ [[nodiscard]] auto drop_index(std::string bucket_name, std::string index_name, const drop_query_index_options& options)
178
+ -> std::future<manager_error_context>
179
+ {
180
+ auto barrier = std::make_shared<std::promise<manager_error_context>>();
181
+ auto future = barrier->get_future();
182
+ drop_index(std::move(bucket_name), std::move(index_name), options, [barrier](auto ctx) { barrier->set_value(ctx); });
183
+ return future;
184
+ }
45
185
  /**
46
186
  * Builds all currently deferred indexes.
47
187
  *
48
- * By default, this method will build the indexes on the bucket. If the indexes should be built on a collection, both
49
- * {@link build_query_index_options#scope_name} and {@link build_query_index_options#collection_name} must be set.
188
+ * By default, this method will build the indexes on the bucket.
50
189
  *
51
- * @tparam Handler
52
190
  * @param bucket_name name of the bucket
53
191
  * @param options the custom options
54
192
  * @param handler the handler that implements @ref build_deferred_query_indexes_handler
193
+ *
194
+ * @since 1.0.0
195
+ * @committed
55
196
  */
56
- template<typename Handler>
57
- void build_deferred_indexes(std::string bucket_name, const build_query_index_options& options, Handler&& handler) const
197
+ void build_deferred_indexes(std::string bucket_name,
198
+ const build_query_index_options& options,
199
+ build_deferred_query_indexes_handler&& handler) const
58
200
  {
59
201
  return core::impl::initiate_build_deferred_indexes(
60
- core_, std::move(bucket_name), std::move(options.build()), std::forward<Handler>(handler));
202
+ core_, std::move(bucket_name), options.build(), std::forward<build_deferred_query_indexes_handler>(handler));
61
203
  }
62
204
 
63
205
  [[nodiscard]] auto build_deferred_indexes(std::string bucket_name, const build_query_index_options& options) const
@@ -69,6 +211,36 @@ class query_index_manager
69
211
  return future;
70
212
  }
71
213
 
214
+ /**
215
+ * Polls the state of a set of indexes, until they all are online.
216
+ *
217
+ * @param bucket_name name of the bucket in which to look for the indexes
218
+ * @param index_names names of the indexes to watch
219
+ * @param options optional parameters
220
+ * @param handler handler that implements @ref watch_query_indexes_handler
221
+ *
222
+ * @since 1.0.0
223
+ * @committed
224
+ */
225
+ void watch_indexes(std::string bucket_name,
226
+ std::vector<std::string> index_names,
227
+ const watch_query_indexes_options& options,
228
+ watch_query_indexes_handler&& handler)
229
+ {
230
+ return core::impl::initiate_watch_query_indexes(
231
+ core_, std::move(bucket_name), std::move(index_names), options.build(), std::move(handler));
232
+ }
233
+
234
+ [[nodiscard]] auto watch_indexes(std::string bucket_name,
235
+ std::vector<std::string> index_names,
236
+ const watch_query_indexes_options& options)
237
+ {
238
+ auto barrier = std::make_shared<std::promise<manager_error_context>>();
239
+ auto future = barrier->get_future();
240
+ watch_indexes(std::move(bucket_name), std::move(index_names), options, [barrier](auto ctx) { barrier->set_value(ctx); });
241
+ return future;
242
+ }
243
+
72
244
  private:
73
245
  friend class cluster;
74
246