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
@@ -57,7 +57,6 @@ struct query_options : public common_options<query_options> {
57
57
  std::optional<std::chrono::milliseconds> scan_wait;
58
58
  std::optional<std::uint64_t> pipeline_batch;
59
59
  std::optional<std::uint64_t> pipeline_cap;
60
- std::optional<std::string> scope_qualifier;
61
60
  std::optional<std::string> client_context_id;
62
61
  std::optional<query_scan_consistency> scan_consistency;
63
62
  std::vector<mutation_token> mutation_state;
@@ -91,7 +90,6 @@ struct query_options : public common_options<query_options> {
91
90
  scan_wait_,
92
91
  pipeline_batch_,
93
92
  pipeline_cap_,
94
- scope_qualifier_,
95
93
  client_context_id_,
96
94
  scan_consistency_,
97
95
  mutation_state_,
@@ -342,19 +340,6 @@ struct query_options : public common_options<query_options> {
342
340
  return self();
343
341
  }
344
342
 
345
- /**
346
- * @param scope_qualifier
347
- * @return this options builder for chaining purposes.
348
- *
349
- * @since 1.0.0
350
- * @volatile
351
- */
352
- auto scope_qualifier(std::string scope_qualifier) -> query_options&
353
- {
354
- scope_qualifier_ = std::move(scope_qualifier);
355
- return self();
356
- }
357
-
358
343
  /**
359
344
  * Customizes the consistency guarantees for this query.
360
345
  *
@@ -549,7 +534,6 @@ struct query_options : public common_options<query_options> {
549
534
  std::optional<std::uint64_t> scan_cap_{};
550
535
  std::optional<std::uint64_t> pipeline_batch_{};
551
536
  std::optional<std::uint64_t> pipeline_cap_{};
552
- std::optional<std::string> scope_qualifier_{};
553
537
  std::optional<std::string> client_context_id_{};
554
538
  std::optional<std::chrono::milliseconds> scan_wait_{};
555
539
  std::optional<query_scan_consistency> scan_consistency_{};
@@ -582,8 +566,7 @@ namespace impl
582
566
  void
583
567
  initiate_query_operation(std::shared_ptr<couchbase::core::cluster> core,
584
568
  std::string statement,
585
- std::optional<std::string> bucket_name,
586
- std::optional<std::string> scope_name,
569
+ std::optional<std::string> query_context,
587
570
  query_options::built options,
588
571
  query_handler&& handler);
589
572
  #endif
@@ -104,8 +104,11 @@ class scope
104
104
  template<typename Handler>
105
105
  void query(std::string statement, const query_options& options, Handler&& handler) const
106
106
  {
107
- return core::impl::initiate_query_operation(
108
- core_, std::move(statement), bucket_name_, name_, options.build(), std::forward<Handler>(handler));
107
+ return core::impl::initiate_query_operation(core_,
108
+ std::move(statement),
109
+ fmt::format("default:`{}`.`{}`", bucket_name_, name_),
110
+ options.build(),
111
+ std::forward<Handler>(handler));
109
112
  }
110
113
 
111
114
  /**
@@ -72,6 +72,22 @@ class request_tracer
72
72
  request_tracer& operator=(request_tracer&& other) = default;
73
73
  virtual ~request_tracer() = default;
74
74
 
75
+ /**
76
+ * SDK invokes this method when cluster is ready to trace. Override it as NO-OP if no action is necessary.
77
+ */
78
+ virtual void start()
79
+ {
80
+ /* do nothing */
81
+ }
82
+
83
+ /**
84
+ * SDK invokes this method when cluster is closed. Override it as NO-OP if no action is necessary.
85
+ */
86
+ virtual void stop()
87
+ {
88
+ /* do nothing */
89
+ }
90
+
75
91
  virtual std::shared_ptr<request_span> start_span(std::string name, std::shared_ptr<request_span> parent = {}) = 0;
76
92
  };
77
93
 
@@ -53,19 +53,26 @@ class async_attempt_context
53
53
 
54
54
  void query(const scope& scope, std::string statement, transaction_query_options opts, async_query_handler&& handler)
55
55
  {
56
- opts.scope_qualifier(fmt::format("{}.{}", scope.bucket_name(), scope.name()));
57
- return query(std::move(statement), std::move(opts), std::move(handler));
56
+ return query(std::move(statement), std::move(opts), fmt::format("{}.{}", scope.bucket_name(), scope.name()), std::move(handler));
58
57
  }
59
58
 
60
- virtual void query(std::string statement, transaction_query_options opts, async_query_handler&& handler) = 0;
59
+ void query(std::string statement, transaction_query_options opts, async_query_handler&& handler)
60
+ {
61
+ return query(statement, opts, {}, std::move(handler));
62
+ };
63
+
61
64
  void query(std::string statement, async_query_handler&& handler)
62
65
  {
63
- return query(statement, {}, std::move(handler));
66
+ return query(statement, {}, {}, std::move(handler));
64
67
  }
65
68
  virtual ~async_attempt_context() = default;
66
69
 
67
70
  protected:
68
71
  virtual void insert_raw(const collection& coll, std::string id, std::vector<std::byte> content, async_result_handler&& handler) = 0;
69
72
  virtual void replace_raw(transaction_get_result_ptr doc, std::vector<std::byte> content, async_result_handler&& handler) = 0;
73
+ virtual void query(std::string statement,
74
+ transaction_query_options opts,
75
+ std::optional<std::string> query_context,
76
+ async_query_handler&&) = 0;
70
77
  };
71
78
  } // namespace couchbase::transactions
@@ -50,13 +50,13 @@ class attempt_context
50
50
 
51
51
  transaction_query_result_ptr query(const std::string& statement, const transaction_query_options& options = {})
52
52
  {
53
- return do_public_query(statement, options);
53
+ return do_public_query(statement, options, {});
54
54
  }
55
55
 
56
56
  transaction_query_result_ptr query(const scope& scope, std::string& statement, const transaction_query_options& opts = {})
57
57
  {
58
58
  auto new_opts = opts;
59
- return query(statement, new_opts.scope_qualifier(fmt::format("{}.{}", scope.bucket_name(), scope.name())));
59
+ return do_public_query(statement, opts, fmt::format("{}.{}", scope.bucket_name(), scope.name()));
60
60
  }
61
61
 
62
62
  virtual ~attempt_context() = default;
@@ -66,6 +66,8 @@ class attempt_context
66
66
  virtual transaction_get_result_ptr insert_raw(const couchbase::collection& coll,
67
67
  const std::string& id,
68
68
  std::vector<std::byte> content) = 0;
69
- virtual transaction_query_result_ptr do_public_query(const std::string& statement, const transaction_query_options& options) = 0;
69
+ virtual transaction_query_result_ptr do_public_query(const std::string& statement,
70
+ const transaction_query_options& options,
71
+ std::optional<std::string> query_context) = 0;
70
72
  };
71
73
  } // namespace couchbase::transactions
@@ -18,6 +18,7 @@
18
18
  #include "couchbase/collection.hxx"
19
19
  #include "couchbase/scope.hxx"
20
20
 
21
+ #include <fmt/format.h>
21
22
  #include <string>
22
23
  #include <utility>
23
24
 
@@ -83,3 +84,18 @@ struct transaction_keyspace {
83
84
  }
84
85
  };
85
86
  } // namespace couchbase::transactions
87
+ template<>
88
+ struct fmt::formatter<couchbase::transactions::transaction_keyspace> {
89
+ public:
90
+ template<typename ParseContext>
91
+ constexpr auto parse(ParseContext& ctx)
92
+ {
93
+ return ctx.begin();
94
+ }
95
+
96
+ template<typename FormatContext>
97
+ auto format(const couchbase::transactions::transaction_keyspace& k, FormatContext& ctx) const
98
+ {
99
+ return format_to(ctx.out(), "transaction_keyspace:{{ bucket: {}, scope: {}, collection: {} }}", k.bucket, k.scope, k.collection);
100
+ }
101
+ };
@@ -114,12 +114,6 @@ class transaction_query_options
114
114
  return *this;
115
115
  }
116
116
 
117
- transaction_query_options& scope_qualifier(const std::string& scope)
118
- {
119
- opts_.scope_qualifier(scope);
120
- return *this;
121
- }
122
-
123
117
  transaction_query_options& metrics(bool metrics)
124
118
  {
125
119
  opts_.metrics(metrics);
@@ -0,0 +1,115 @@
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 watch_query_indexes_options : public common_options<watch_query_indexes_options>
30
+ {
31
+ public:
32
+ auto watch_primary(bool watch_primary) -> watch_query_indexes_options&
33
+ {
34
+ watch_primary_ = watch_primary;
35
+ return self();
36
+ }
37
+
38
+ template<typename T>
39
+ auto polling_interval(T duration)
40
+ {
41
+ polling_interval_ = std::chrono::duration_cast<std::chrono::milliseconds>(duration);
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<watch_query_indexes_options>::built {
52
+ bool watch_primary{};
53
+ std::chrono::milliseconds polling_interval;
54
+ };
55
+
56
+ /**
57
+ * Validates options and returns them as an immutable value.
58
+ *
59
+ * @return consistent options as an immutable value
60
+ *
61
+ * @exception std::system_error with code errc::common::invalid_argument if the options are not valid
62
+ *
63
+ * @since 1.0.0
64
+ * @internal
65
+ */
66
+ [[nodiscard]] auto build() const -> built
67
+ {
68
+ return { build_common_options(), watch_primary_, polling_interval_ };
69
+ }
70
+
71
+ private:
72
+ bool watch_primary_{ false };
73
+ std::chrono::milliseconds polling_interval_{ 1000 };
74
+ };
75
+
76
+ /**
77
+ * The signature for the handler of the @ref query_index_manager#get_all_indexes() operation
78
+ *
79
+ * @since 1.0.0
80
+ * @uncommitted
81
+ */
82
+
83
+ using watch_query_indexes_handler = std::function<void(couchbase::manager_error_context)>;
84
+
85
+ #ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
86
+ namespace core
87
+ {
88
+ class cluster;
89
+ class query_context;
90
+ namespace impl
91
+ {
92
+
93
+ /**
94
+ * @since 1.0.0
95
+ * @internal
96
+ */
97
+ void
98
+ initiate_watch_query_indexes(std::shared_ptr<couchbase::core::cluster> core,
99
+ std::string bucket_name,
100
+ std::vector<std::string> index_names,
101
+ couchbase::watch_query_indexes_options::built options,
102
+ query_context query_ctx,
103
+ std::string collection_name,
104
+ watch_query_indexes_handler&& handler);
105
+ void
106
+ initiate_watch_query_indexes(std::shared_ptr<couchbase::core::cluster> core,
107
+ std::string bucket_name,
108
+ std::vector<std::string> index_names,
109
+ couchbase::watch_query_indexes_options::built options,
110
+ watch_query_indexes_handler&& handler);
111
+
112
+ #endif
113
+ } // namespace impl
114
+ } // namespace core
115
+ } // namespace couchbase
@@ -44,7 +44,9 @@ main()
44
44
  auto options = couchbase::cluster_options(username, password);
45
45
  options.apply_profile("wan_development");
46
46
  auto [cluster, ec] = couchbase::cluster::connect(io, connection_string, options).get();
47
- {
47
+ if (ec) {
48
+ std::cout << "Unable to connect to the cluster. ec: " << ec.message() << "\n";
49
+ } else {
48
50
  auto collection = cluster.bucket(bucket_name).scope(scope_name).collection(collection_name);
49
51
 
50
52
  const std::string document_id{ "minimal_example" };
@@ -29,6 +29,32 @@ static const tao::json::value basic_doc = {
29
29
  };
30
30
  static const std::vector<std::byte> basic_doc_json = couchbase::core::utils::json::generate_binary(basic_doc);
31
31
 
32
+ TEST_CASE("integration: switching off mutation token", "[integration]")
33
+ {
34
+ couchbase::core::cluster_options opts{};
35
+ opts.enable_mutation_tokens = false;
36
+ test::utils::integration_test_guard integration(opts);
37
+
38
+ test::utils::open_bucket(integration.cluster, integration.ctx.bucket);
39
+ couchbase::core::document_id id{ integration.ctx.bucket, "_default", "_default", test::utils::uniq_id("foo") };
40
+
41
+ {
42
+ couchbase::core::operations::insert_request req{ id, basic_doc_json };
43
+ auto resp = test::utils::execute(integration.cluster, req);
44
+ REQUIRE_SUCCESS(resp.ctx.ec());
45
+ REQUIRE(!resp.cas.empty());
46
+ REQUIRE(resp.token.sequence_number() == 0);
47
+ REQUIRE(resp.token.partition_uuid() == 0);
48
+ REQUIRE_FALSE(resp.token.partition_id() == 0);
49
+ REQUIRE_FALSE(resp.token.bucket_name().empty());
50
+ }
51
+ {
52
+ couchbase::core::operations::get_request req{ id };
53
+ auto resp = test::utils::execute(integration.cluster, req);
54
+ REQUIRE(resp.value == basic_doc_json);
55
+ }
56
+ }
57
+
32
58
  TEST_CASE("integration: crud on default collection", "[integration]")
33
59
  {
34
60
  test::utils::integration_test_guard integration;
@@ -868,3 +894,49 @@ TEST_CASE("integration: exists with public API", "[integration]")
868
894
  REQUIRE_FALSE(resp.exists());
869
895
  }
870
896
  }
897
+
898
+ TEST_CASE("integration: get with expiry with public API", "[integration]")
899
+ {
900
+ test::utils::integration_test_guard integration;
901
+ test::utils::open_bucket(integration.cluster, integration.ctx.bucket);
902
+
903
+ auto collection = couchbase::cluster(integration.cluster)
904
+ .bucket(integration.ctx.bucket)
905
+ .scope(couchbase::scope::default_name)
906
+ .collection(couchbase::collection::default_name);
907
+
908
+ auto id = test::utils::uniq_id("get_expiry");
909
+
910
+ auto get_options = couchbase::get_options{}.with_expiry(true);
911
+
912
+ SECTION("no expiry set on the document")
913
+ {
914
+ {
915
+ auto [ctx, resp] = collection.insert(id, basic_doc, {}).get();
916
+ REQUIRE_SUCCESS(ctx.ec());
917
+ }
918
+
919
+ {
920
+ auto [ctx, resp] = collection.get(id, get_options).get();
921
+ REQUIRE_SUCCESS(ctx.ec());
922
+ REQUIRE_FALSE(resp.expiry_time().has_value());
923
+ }
924
+ }
925
+
926
+ SECTION("some expiry is set on the document")
927
+ {
928
+ auto the_expiry = std::chrono::system_clock::from_time_t(1878422400);
929
+ auto insert_options = couchbase::insert_options{}.expiry(the_expiry);
930
+ {
931
+ auto [ctx, resp] = collection.insert(id, basic_doc, insert_options).get();
932
+ REQUIRE_SUCCESS(ctx.ec());
933
+ }
934
+
935
+ {
936
+ auto [ctx, resp] = collection.get(id, get_options).get();
937
+ REQUIRE_SUCCESS(ctx.ec());
938
+ REQUIRE(resp.expiry_time().has_value());
939
+ REQUIRE(resp.expiry_time().value() == the_expiry);
940
+ }
941
+ }
942
+ }