couchbase 3.4.3 → 3.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/ext/couchbase/CMakeLists.txt +15 -1
  4. data/ext/couchbase/core/bucket.cxx +183 -152
  5. data/ext/couchbase/core/bucket.hxx +17 -4
  6. data/ext/couchbase/core/cluster.hxx +34 -13
  7. data/ext/couchbase/core/cluster_options.hxx +3 -0
  8. data/ext/couchbase/core/crud_component.cxx +51 -22
  9. data/ext/couchbase/core/error_context/key_value.cxx +2 -1
  10. data/ext/couchbase/core/error_context/key_value.hxx +10 -12
  11. data/ext/couchbase/core/impl/build_deferred_query_indexes.cxx +115 -50
  12. data/ext/couchbase/core/impl/cluster.cxx +6 -0
  13. data/ext/couchbase/core/impl/create_bucket.cxx +155 -0
  14. data/ext/couchbase/core/impl/create_query_index.cxx +172 -59
  15. data/ext/couchbase/core/impl/dns_srv_tracker.cxx +2 -1
  16. data/ext/couchbase/core/impl/drop_bucket.cxx +66 -0
  17. data/ext/couchbase/core/impl/drop_query_index.cxx +138 -59
  18. data/ext/couchbase/core/impl/flush_bucket.cxx +66 -0
  19. data/ext/couchbase/core/impl/get_all_buckets.cxx +163 -0
  20. data/ext/couchbase/core/impl/get_all_query_indexes.cxx +67 -37
  21. data/ext/couchbase/core/impl/get_bucket.cxx +153 -0
  22. data/ext/couchbase/core/impl/internal_manager_error_context.cxx +113 -0
  23. data/ext/couchbase/core/impl/internal_manager_error_context.hxx +60 -0
  24. data/ext/couchbase/core/impl/key_value_error_category.cxx +2 -4
  25. data/ext/couchbase/core/impl/key_value_error_context.cxx +98 -0
  26. data/ext/couchbase/core/impl/lookup_in.cxx +1 -0
  27. data/ext/couchbase/core/impl/lookup_in_all_replicas.cxx +176 -0
  28. data/ext/couchbase/core/impl/lookup_in_all_replicas.hxx +80 -0
  29. data/ext/couchbase/core/impl/lookup_in_any_replica.cxx +167 -0
  30. data/ext/couchbase/core/impl/lookup_in_any_replica.hxx +75 -0
  31. data/ext/couchbase/core/impl/lookup_in_replica.cxx +97 -0
  32. data/ext/couchbase/core/impl/lookup_in_replica.hxx +67 -0
  33. data/ext/couchbase/core/impl/manager_error_context.cxx +100 -0
  34. data/ext/couchbase/core/impl/query.cxx +1 -0
  35. data/ext/couchbase/core/impl/query_error_context.cxx +75 -0
  36. data/ext/couchbase/core/impl/update_bucket.cxx +130 -0
  37. data/ext/couchbase/core/impl/watch_query_indexes.cxx +53 -29
  38. data/ext/couchbase/core/io/dns_client.cxx +111 -40
  39. data/ext/couchbase/core/io/dns_config.cxx +5 -4
  40. data/ext/couchbase/core/io/http_session.hxx +24 -1
  41. data/ext/couchbase/core/io/mcbp_command.hxx +9 -2
  42. data/ext/couchbase/core/io/mcbp_session.cxx +80 -43
  43. data/ext/couchbase/core/io/mcbp_session.hxx +4 -3
  44. data/ext/couchbase/core/logger/custom_rotating_file_sink.cxx +1 -1
  45. data/ext/couchbase/core/logger/logger.cxx +80 -20
  46. data/ext/couchbase/core/logger/logger.hxx +31 -0
  47. data/ext/couchbase/core/meta/features.hxx +25 -0
  48. data/ext/couchbase/core/operations/document_lookup_in_all_replicas.hxx +192 -0
  49. data/ext/couchbase/core/operations/document_lookup_in_any_replica.hxx +188 -0
  50. data/ext/couchbase/core/operations/document_query.cxx +11 -0
  51. data/ext/couchbase/core/operations/document_query.hxx +1 -0
  52. data/ext/couchbase/core/operations.hxx +2 -0
  53. data/ext/couchbase/core/origin.cxx +270 -0
  54. data/ext/couchbase/core/origin.hxx +2 -0
  55. data/ext/couchbase/core/protocol/client_response.hxx +1 -0
  56. data/ext/couchbase/core/protocol/cmd_hello.hxx +1 -0
  57. data/ext/couchbase/core/protocol/cmd_lookup_in_replica.cxx +107 -0
  58. data/ext/couchbase/core/protocol/cmd_lookup_in_replica.hxx +137 -0
  59. data/ext/couchbase/core/protocol/hello_feature.hxx +6 -0
  60. data/ext/couchbase/core/protocol/hello_feature_fmt.hxx +3 -0
  61. data/ext/couchbase/core/protocol/status.cxx +2 -2
  62. data/ext/couchbase/core/range_scan_options.cxx +3 -27
  63. data/ext/couchbase/core/range_scan_options.hxx +13 -17
  64. data/ext/couchbase/core/range_scan_orchestrator.cxx +388 -170
  65. data/ext/couchbase/core/range_scan_orchestrator.hxx +13 -2
  66. data/ext/couchbase/core/range_scan_orchestrator_options.hxx +5 -3
  67. data/ext/couchbase/core/scan_options.hxx +0 -19
  68. data/ext/couchbase/core/scan_result.cxx +19 -5
  69. data/ext/couchbase/core/scan_result.hxx +5 -2
  70. data/ext/couchbase/core/timeout_defaults.hxx +2 -3
  71. data/ext/couchbase/core/topology/capabilities.hxx +3 -0
  72. data/ext/couchbase/core/topology/capabilities_fmt.hxx +8 -0
  73. data/ext/couchbase/core/topology/collections_manifest_fmt.hxx +1 -1
  74. data/ext/couchbase/core/topology/configuration.hxx +15 -0
  75. data/ext/couchbase/core/topology/configuration_json.hxx +6 -1
  76. data/ext/couchbase/core/utils/connection_string.cxx +62 -47
  77. data/ext/couchbase/core/utils/connection_string.hxx +1 -0
  78. data/ext/couchbase/couchbase/analytics_error_context.hxx +1 -1
  79. data/ext/couchbase/couchbase/behavior_options.hxx +19 -2
  80. data/ext/couchbase/couchbase/bucket_manager.hxx +135 -0
  81. data/ext/couchbase/couchbase/build_query_index_options.hxx +0 -30
  82. data/ext/couchbase/couchbase/cluster.hxx +14 -0
  83. data/ext/couchbase/couchbase/collection.hxx +111 -0
  84. data/ext/couchbase/couchbase/collection_query_index_manager.hxx +7 -48
  85. data/ext/couchbase/couchbase/create_bucket_options.hxx +41 -0
  86. data/ext/couchbase/couchbase/create_primary_query_index_options.hxx +0 -29
  87. data/ext/couchbase/couchbase/create_query_index_options.hxx +0 -33
  88. data/ext/couchbase/couchbase/drop_bucket_options.hxx +41 -0
  89. data/ext/couchbase/couchbase/drop_primary_query_index_options.hxx +0 -30
  90. data/ext/couchbase/couchbase/drop_query_index_options.hxx +0 -31
  91. data/ext/couchbase/couchbase/error_codes.hxx +1 -2
  92. data/ext/couchbase/couchbase/error_context.hxx +10 -2
  93. data/ext/couchbase/couchbase/flush_bucket_options.hxx +41 -0
  94. data/ext/couchbase/{core/topology/error_map_fmt.hxx → couchbase/fmt/key_value_error_map_attribute.hxx} +21 -21
  95. data/ext/couchbase/couchbase/get_all_buckets_options.hxx +44 -0
  96. data/ext/couchbase/couchbase/get_all_query_indexes_options.hxx +0 -30
  97. data/ext/couchbase/couchbase/get_and_lock_options.hxx +2 -2
  98. data/ext/couchbase/couchbase/get_and_touch_options.hxx +2 -2
  99. data/ext/couchbase/couchbase/get_bucket_options.hxx +43 -0
  100. data/ext/couchbase/couchbase/get_options.hxx +2 -2
  101. data/ext/couchbase/couchbase/insert_options.hxx +3 -3
  102. data/ext/couchbase/couchbase/key_value_error_context.hxx +7 -2
  103. data/ext/couchbase/couchbase/lookup_in_all_replicas_options.hxx +109 -0
  104. data/ext/couchbase/couchbase/lookup_in_any_replica_options.hxx +101 -0
  105. data/ext/couchbase/couchbase/lookup_in_options.hxx +2 -2
  106. data/ext/couchbase/couchbase/lookup_in_replica_result.hxx +74 -0
  107. data/ext/couchbase/couchbase/lookup_in_result.hxx +26 -0
  108. data/ext/couchbase/couchbase/management/bucket_settings.hxx +116 -0
  109. data/ext/couchbase/couchbase/manager_error_context.hxx +29 -53
  110. data/ext/couchbase/couchbase/mutate_in_options.hxx +2 -2
  111. data/ext/couchbase/couchbase/query_error_context.hxx +3 -1
  112. data/ext/couchbase/couchbase/query_index_manager.hxx +16 -83
  113. data/ext/couchbase/couchbase/query_options.hxx +18 -0
  114. data/ext/couchbase/couchbase/remove_options.hxx +2 -2
  115. data/ext/couchbase/couchbase/replace_options.hxx +3 -3
  116. data/ext/couchbase/couchbase/security_options.hxx +15 -0
  117. data/ext/couchbase/couchbase/subdocument_error_context.hxx +4 -2
  118. data/ext/couchbase/couchbase/touch_options.hxx +2 -2
  119. data/ext/couchbase/couchbase/unlock_options.hxx +2 -2
  120. data/ext/couchbase/couchbase/update_bucket_options.hxx +41 -0
  121. data/ext/couchbase/couchbase/upsert_options.hxx +3 -3
  122. data/ext/couchbase/couchbase/watch_query_indexes_options.hxx +0 -31
  123. data/ext/couchbase/test/CMakeLists.txt +1 -0
  124. data/ext/couchbase/test/test_integration_collections.cxx +6 -0
  125. data/ext/couchbase/test/test_integration_crud.cxx +5 -0
  126. data/ext/couchbase/test/test_integration_examples.cxx +137 -1
  127. data/ext/couchbase/test/test_integration_management.cxx +709 -266
  128. data/ext/couchbase/test/test_integration_query.cxx +19 -7
  129. data/ext/couchbase/test/test_integration_range_scan.cxx +351 -112
  130. data/ext/couchbase/test/test_integration_search.cxx +10 -1
  131. data/ext/couchbase/test/test_integration_subdoc.cxx +655 -0
  132. data/ext/couchbase/test/test_transaction_public_async_api.cxx +13 -12
  133. data/ext/couchbase/test/test_transaction_public_blocking_api.cxx +27 -21
  134. data/ext/couchbase/test/test_unit_connection_string.cxx +29 -0
  135. data/ext/couchbase/test/test_unit_query.cxx +75 -0
  136. data/ext/couchbase.cxx +583 -29
  137. data/ext/revisions.rb +3 -3
  138. data/lib/couchbase/cluster.rb +1 -1
  139. data/lib/couchbase/collection.rb +108 -0
  140. data/lib/couchbase/collection_options.rb +100 -0
  141. data/lib/couchbase/errors.rb +5 -0
  142. data/lib/couchbase/key_value_scan.rb +125 -0
  143. data/lib/couchbase/options.rb +151 -0
  144. data/lib/couchbase/scope.rb +1 -1
  145. data/lib/couchbase/utils/time.rb +14 -1
  146. data/lib/couchbase/version.rb +1 -1
  147. metadata +41 -7
  148. data/ext/couchbase/core/impl/collection_query_index_manager.cxx +0 -93
@@ -0,0 +1,135 @@
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/create_bucket_options.hxx>
21
+ #include <couchbase/drop_bucket_options.hxx>
22
+ #include <couchbase/flush_bucket_options.hxx>
23
+ #include <couchbase/get_all_buckets_options.hxx>
24
+ #include <couchbase/get_bucket_options.hxx>
25
+ #include <couchbase/update_bucket_options.hxx>
26
+
27
+ #include <future>
28
+ #include <memory>
29
+
30
+ #ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
31
+ namespace couchbase::core
32
+ {
33
+ class cluster;
34
+ } // namespace couchbase::core
35
+ #endif
36
+
37
+ namespace couchbase
38
+ {
39
+ class cluster;
40
+
41
+ class bucket_manager
42
+ {
43
+ public:
44
+ /**
45
+ * Get specific bucket within the cluster
46
+ *
47
+ * @param bucket_name the name of the bucket to get
48
+ * @param options optional parameters
49
+ * @param handler handler that implements @ref get_bucket_handler
50
+ *
51
+ * @since 1.0.0
52
+ * @committed
53
+ */
54
+ void get_bucket(std::string bucket_name, const get_bucket_options& options, get_bucket_handler&& handler) const;
55
+
56
+ [[nodiscard]] auto get_bucket(std::string bucket_name, const get_bucket_options& options = {}) const
57
+ -> std::future<std::pair<manager_error_context, management::cluster::bucket_settings>>;
58
+
59
+ /**
60
+ * Get all buckets on the cluster
61
+ *
62
+ * @param options optional parameters
63
+ * @param handler handler that implements @ref get_all_buckets_handler
64
+ *
65
+ * @since 1.0.0
66
+ * @committed
67
+ */
68
+ void get_all_buckets(const get_all_buckets_options& options, get_all_buckets_handler&& handler) const;
69
+
70
+ [[nodiscard]] auto get_all_buckets(const get_all_buckets_options& options = {}) const
71
+ -> std::future<std::pair<manager_error_context, std::vector<management::cluster::bucket_settings>>>;
72
+
73
+ /**
74
+ * Create a bucket on the cluster
75
+ *
76
+ * @param bucket_settings the settings for the bucket
77
+ * @param options optional parameters
78
+ * @param handler handler that implements @ref create_bucket_handler
79
+ */
80
+ void create_bucket(const management::cluster::bucket_settings& bucket_settings,
81
+ const create_bucket_options& options,
82
+ create_bucket_handler&& handler) const;
83
+
84
+ [[nodiscard]] auto create_bucket(const management::cluster::bucket_settings& bucket_settings,
85
+ const create_bucket_options& options = {}) const -> std::future<manager_error_context>;
86
+
87
+ /**
88
+ * Update an existing bucket
89
+ *
90
+ * @param bucket_settings the settings for the bucket
91
+ * @param options optional parameters
92
+ * @param handler handler that implements @ref update_bucket_handler
93
+ */
94
+ void update_bucket(const management::cluster::bucket_settings& bucket_settings,
95
+ const update_bucket_options& options,
96
+ update_bucket_handler&& handler) const;
97
+
98
+ [[nodiscard]] auto update_bucket(const management::cluster::bucket_settings& bucket_settings,
99
+ const update_bucket_options& options = {}) const -> std::future<manager_error_context>;
100
+
101
+ /**
102
+ * Drop an existing bucket
103
+ *
104
+ * @param bucket_name the name of the bucket to drop
105
+ * @param options optional parameters
106
+ * @param handler handler that implements @ref drop_bucket_handler
107
+ */
108
+ void drop_bucket(std::string bucket_name, const drop_bucket_options& options, drop_bucket_handler&& handler) const;
109
+
110
+ [[nodiscard]] auto drop_bucket(std::string bucket_name, const drop_bucket_options& options = {}) const
111
+ -> std::future<manager_error_context>;
112
+
113
+ /**
114
+ * Flush an existing bucket
115
+ *
116
+ * @param bucket_name the name of the bucket to flush
117
+ * @param options optional parameters
118
+ * @param handler handler that implements @ref flush_bucket_handler
119
+ */
120
+ void flush_bucket(std::string bucket_name, const flush_bucket_options& options, flush_bucket_handler&& handler) const;
121
+
122
+ [[nodiscard]] auto flush_bucket(std::string bucket_name, const flush_bucket_options& options = {}) const
123
+ -> std::future<manager_error_context>;
124
+
125
+ private:
126
+ friend class cluster;
127
+
128
+ explicit bucket_manager(std::shared_ptr<couchbase::core::cluster> core)
129
+ : core_(std::move(core))
130
+ {
131
+ }
132
+
133
+ std::shared_ptr<couchbase::core::cluster> core_;
134
+ };
135
+ } // namespace couchbase
@@ -66,34 +66,4 @@ class build_query_index_options : public common_options<build_query_index_option
66
66
  * @uncommitted
67
67
  */
68
68
  using build_deferred_query_indexes_handler = std::function<void(couchbase::manager_error_context)>;
69
-
70
- #ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
71
- namespace core
72
- {
73
- class cluster;
74
- class query_context;
75
- namespace impl
76
- {
77
-
78
- /**
79
- * @since 1.0.0
80
- * @internal
81
- */
82
- void
83
- initiate_build_deferred_indexes(std::shared_ptr<couchbase::core::cluster> resp1,
84
- std::string bucket_name,
85
- build_query_index_options::built options,
86
- query_context query_ctx,
87
- std::string collection_name,
88
- build_deferred_query_indexes_handler&& handler);
89
-
90
- void
91
- initiate_build_deferred_indexes(std::shared_ptr<couchbase::core::cluster> resp1,
92
- std::string bucket_name,
93
- build_query_index_options::built options,
94
- build_deferred_query_indexes_handler&& handler);
95
-
96
- #endif
97
- } // namespace impl
98
- } // namespace core
99
69
  } // namespace couchbase
@@ -19,6 +19,7 @@
19
19
 
20
20
  #include <couchbase/analytics_options.hxx>
21
21
  #include <couchbase/bucket.hxx>
22
+ #include <couchbase/bucket_manager.hxx>
22
23
  #include <couchbase/cluster_options.hxx>
23
24
  #include <couchbase/query_index_manager.hxx>
24
25
  #include <couchbase/query_options.hxx>
@@ -250,6 +251,19 @@ class cluster
250
251
  return query_index_manager{ core_ };
251
252
  }
252
253
 
254
+ /**
255
+ * Provides access to the bucket management services.
256
+ *
257
+ * @return a manager instance
258
+ *
259
+ * @since 1.0.0
260
+ * @committed
261
+ */
262
+ [[nodiscard]] auto buckets() const -> bucket_manager
263
+ {
264
+ return bucket_manager{ core_ };
265
+ }
266
+
253
267
  /**
254
268
  * Provides access to transaction services.
255
269
  *
@@ -28,6 +28,8 @@
28
28
  #include <couchbase/get_any_replica_options.hxx>
29
29
  #include <couchbase/get_options.hxx>
30
30
  #include <couchbase/insert_options.hxx>
31
+ #include <couchbase/lookup_in_all_replicas_options.hxx>
32
+ #include <couchbase/lookup_in_any_replica_options.hxx>
31
33
  #include <couchbase/lookup_in_options.hxx>
32
34
  #include <couchbase/lookup_in_specs.hxx>
33
35
  #include <couchbase/mutate_in_options.hxx>
@@ -856,6 +858,115 @@ class collection
856
858
  return future;
857
859
  }
858
860
 
861
+ /**
862
+ * Performs lookups to document fragments with default options from all replicas and the active node and returns the result as a vector.
863
+ *
864
+ * @tparam Handler type of the handler that implements @ref lookup_in_all_replicas_handler
865
+ *
866
+ * @param document_id the outer document ID
867
+ * @param specs an object that specifies the types of lookups to perform
868
+ * @param options custom options to modify the lookup options
869
+ * @param handler callable that implements @ref lookup_in_all_replicas_handler
870
+ *
871
+ * @exception errc::key_value::document_not_found the given document id is not found in the collection.
872
+ * @exception errc::common::ambiguous_timeout
873
+ * @exception errc::common::unambiguous_timeout
874
+ *
875
+ * @since 1.0.0
876
+ * @committed
877
+ */
878
+ template<typename Handler>
879
+ void lookup_in_all_replicas(std::string document_id,
880
+ lookup_in_specs specs,
881
+ const lookup_in_all_replicas_options& options,
882
+ Handler&& handler) const
883
+ {
884
+ return core::impl::initiate_lookup_in_all_replicas_operation(
885
+ core_, bucket_name_, scope_name_, name_, std::move(document_id), specs.specs(), options.build(), std::forward<Handler>(handler));
886
+ }
887
+
888
+ /**
889
+ * Performs lookups to document fragments with default options from all replicas and the active node and returns the result as a vector.
890
+ *
891
+ * @param document_id the outer document ID
892
+ * @param specs an object that specifies the types of lookups to perform
893
+ * @param options custom options to modify the lookup options
894
+ * @return future object that carries result of the operation
895
+ *
896
+ * @exception errc::key_value::document_not_found the given document id is not found in the collection.
897
+ * @exception errc::common::ambiguous_timeout
898
+ * @exception errc::common::unambiguous_timeout
899
+ *
900
+ * @since 1.0.0
901
+ * @committed
902
+ */
903
+ [[nodiscard]] auto lookup_in_all_replicas(std::string document_id,
904
+ lookup_in_specs specs,
905
+ const lookup_in_all_replicas_options& options = {}) const
906
+ -> std::future<std::pair<subdocument_error_context, lookup_in_all_replicas_result>>
907
+ {
908
+ auto barrier = std::make_shared<std::promise<std::pair<subdocument_error_context, lookup_in_all_replicas_result>>>();
909
+ auto future = barrier->get_future();
910
+ lookup_in_all_replicas(std::move(document_id), std::move(specs), options, [barrier](auto ctx, auto result) {
911
+ barrier->set_value({ std::move(ctx), std::move(result) });
912
+ });
913
+ return future;
914
+ }
915
+
916
+ /**
917
+ * Performs lookups to document fragments with default options from all replicas and returns the first found.
918
+ *
919
+ * @tparam Handler type of the handler that implements @ref lookup_in_any_replica_handler
920
+ *
921
+ * @param document_id the outer document ID
922
+ * @param specs an object that specifies the types of lookups to perform
923
+ * @param options custom options to modify the lookup options
924
+ *
925
+ * @exception errc::key_value::document_not_found the given document id is not found in the collection.
926
+ * @exception errc::common::ambiguous_timeout
927
+ * @exception errc::common::unambiguous_timeout
928
+ *
929
+ * @since 1.0.0
930
+ * @committed
931
+ */
932
+ template<typename Handler>
933
+ void lookup_in_any_replica(std::string document_id,
934
+ lookup_in_specs specs,
935
+ const lookup_in_any_replica_options& options,
936
+ Handler&& handler) const
937
+ {
938
+ return core::impl::initiate_lookup_in_any_replica_operation(
939
+ core_, bucket_name_, scope_name_, name_, std::move(document_id), specs.specs(), options.build(), std::forward<Handler>(handler));
940
+ }
941
+
942
+ /**
943
+ * Performs lookups to document fragments with default options from all replicas and returns the first found.
944
+ *
945
+ * @param document_id the outer document ID
946
+ * @param specs an object that specifies the types of lookups to perform
947
+ * @param options custom options to modify the lookup options
948
+ * @return future object that carries result of the operation
949
+ *
950
+ * @exception errc::key_value::document_not_found the given document id is not found in the collection.
951
+ * @exception errc::common::ambiguous_timeout
952
+ * @exception errc::common::unambiguous_timeout
953
+ *
954
+ * @since 1.0.0
955
+ * @committed
956
+ */
957
+ [[nodiscard]] auto lookup_in_any_replica(std::string document_id,
958
+ lookup_in_specs specs,
959
+ const lookup_in_any_replica_options& options = {}) const
960
+ -> std::future<std::pair<subdocument_error_context, lookup_in_replica_result>>
961
+ {
962
+ auto barrier = std::make_shared<std::promise<std::pair<subdocument_error_context, lookup_in_replica_result>>>();
963
+ auto future = barrier->get_future();
964
+ lookup_in_any_replica(std::move(document_id), std::move(specs), options, [barrier](auto ctx, auto result) {
965
+ barrier->set_value({ std::move(ctx), std::move(result) });
966
+ });
967
+ return future;
968
+ }
969
+
859
970
  /**
860
971
  * Gets a document for a given id and places a pessimistic lock on it for mutations
861
972
  *
@@ -64,13 +64,7 @@ class collection_query_index_manager
64
64
  void get_all_indexes(const get_all_query_indexes_options& options, get_all_query_indexes_handler&& handler) const;
65
65
 
66
66
  [[nodiscard]] auto get_all_indexes(const get_all_query_indexes_options& options) const
67
- -> std::future<std::pair<manager_error_context, std::vector<couchbase::management::query::index>>>
68
- {
69
- auto barrier = std::make_shared<std::promise<std::pair<manager_error_context, std::vector<couchbase::management::query::index>>>>();
70
- auto future = barrier->get_future();
71
- get_all_indexes(options, [barrier](auto ctx, auto resp) { barrier->set_value({ ctx, resp }); });
72
- return future;
73
- }
67
+ -> std::future<std::pair<manager_error_context, std::vector<couchbase::management::query::index>>>;
74
68
  /**
75
69
  * Create an index on the collection.
76
70
  *
@@ -89,13 +83,7 @@ class collection_query_index_manager
89
83
 
90
84
  [[nodiscard]] auto create_index(std::string index_name,
91
85
  std::vector<std::string> fields,
92
- const create_query_index_options& options) const -> std::future<manager_error_context>
93
- {
94
- auto barrier = std::make_shared<std::promise<manager_error_context>>();
95
- auto future = barrier->get_future();
96
- create_index(std::move(index_name), std::move(fields), options, [barrier](auto ctx) { barrier->set_value(ctx); });
97
- return future;
98
- }
86
+ const create_query_index_options& options) const -> std::future<manager_error_context>;
99
87
 
100
88
  /**
101
89
  * Create a primary index on a collection.
@@ -108,13 +96,7 @@ class collection_query_index_manager
108
96
  */
109
97
  void create_primary_index(const create_primary_query_index_options& options, create_query_index_handler&& handler) const;
110
98
 
111
- [[nodiscard]] auto create_primary_index(const create_primary_query_index_options& options) -> std::future<manager_error_context>
112
- {
113
- auto barrier = std::make_shared<std::promise<manager_error_context>>();
114
- auto future = barrier->get_future();
115
- create_primary_index(options, [barrier](auto ctx) { barrier->set_value(ctx); });
116
- return future;
117
- }
99
+ [[nodiscard]] auto create_primary_index(const create_primary_query_index_options& options) -> std::future<manager_error_context>;
118
100
  /**
119
101
  * Drop primary index on a collection.
120
102
  *
@@ -126,13 +108,7 @@ class collection_query_index_manager
126
108
  */
127
109
  void drop_primary_index(const drop_primary_query_index_options& options, drop_query_index_handler&& handler) const;
128
110
 
129
- [[nodiscard]] auto drop_primary_index(const drop_primary_query_index_options& options) const -> std::future<manager_error_context>
130
- {
131
- auto barrier = std::make_shared<std::promise<manager_error_context>>();
132
- auto future = barrier->get_future();
133
- drop_primary_index(options, [barrier](auto ctx) { barrier->set_value(ctx); });
134
- return future;
135
- }
111
+ [[nodiscard]] auto drop_primary_index(const drop_primary_query_index_options& options) const -> std::future<manager_error_context>;
136
112
 
137
113
  /**
138
114
  * Drop index in collection.
@@ -146,13 +122,7 @@ class collection_query_index_manager
146
122
  */
147
123
  void drop_index(std::string index_name, const drop_query_index_options& options, drop_query_index_handler&& handler) const;
148
124
 
149
- [[nodiscard]] auto drop_index(std::string index_name, const drop_query_index_options& options) -> std::future<manager_error_context>
150
- {
151
- auto barrier = std::make_shared<std::promise<manager_error_context>>();
152
- auto future = barrier->get_future();
153
- drop_index(std::move(index_name), options, [barrier](auto ctx) { barrier->set_value(ctx); });
154
- return future;
155
- }
125
+ [[nodiscard]] auto drop_index(std::string index_name, const drop_query_index_options& options) -> std::future<manager_error_context>;
156
126
  /**
157
127
  * Builds all currently deferred indexes in this collection.
158
128
  *
@@ -166,13 +136,7 @@ class collection_query_index_manager
166
136
  */
167
137
  void build_deferred_indexes(const build_query_index_options& options, build_deferred_query_indexes_handler&& handler) const;
168
138
 
169
- [[nodiscard]] auto build_deferred_indexes(const build_query_index_options& options) const -> std::future<manager_error_context>
170
- {
171
- auto barrier = std::make_shared<std::promise<manager_error_context>>();
172
- auto future = barrier->get_future();
173
- build_deferred_indexes(options, [barrier](auto ctx) { barrier->set_value(std::move(ctx)); });
174
- return future;
175
- }
139
+ [[nodiscard]] auto build_deferred_indexes(const build_query_index_options& options) const -> std::future<manager_error_context>;
176
140
 
177
141
  /**
178
142
  * Polls the state of a set of indexes, until they all are online.
@@ -189,12 +153,7 @@ class collection_query_index_manager
189
153
  watch_query_indexes_handler&& handler) const;
190
154
 
191
155
  [[nodiscard]] auto watch_indexes(std::vector<std::string> index_names, const watch_query_indexes_options& options)
192
- {
193
- auto barrier = std::make_shared<std::promise<manager_error_context>>();
194
- auto future = barrier->get_future();
195
- watch_indexes(std::move(index_names), options, [barrier](auto ctx) { barrier->set_value(ctx); });
196
- return future;
197
- }
156
+ -> std::future<manager_error_context>;
198
157
 
199
158
  private:
200
159
  friend class collection;
@@ -0,0 +1,41 @@
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 <functional>
21
+ #include <memory>
22
+ #include <optional>
23
+ #include <string>
24
+
25
+ namespace couchbase
26
+ {
27
+ struct create_bucket_options : public common_options<create_bucket_options> {
28
+ public:
29
+ struct built : public common_options<create_bucket_options>::built {
30
+ };
31
+
32
+ [[nodiscard]] auto build() const -> built
33
+ {
34
+ return { build_common_options() };
35
+ }
36
+
37
+ private:
38
+ };
39
+
40
+ using create_bucket_handler = std::function<void(couchbase::manager_error_context)>;
41
+ } // namespace couchbase
@@ -134,33 +134,4 @@ class create_primary_query_index_options : public common_options<create_primary_
134
134
  */
135
135
 
136
136
  using create_primary_query_index_handler = std::function<void(couchbase::manager_error_context)>;
137
-
138
- #ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
139
- namespace core
140
- {
141
- class cluster;
142
- class query_context;
143
- namespace impl
144
- {
145
-
146
- /**
147
- * @since 1.0.0
148
- * @internal
149
- */
150
- void
151
- initiate_create_primary_query_index(std::shared_ptr<couchbase::core::cluster> core,
152
- std::string bucket_name,
153
- couchbase::create_primary_query_index_options::built options,
154
- query_context query_ctx,
155
- std::string collection_name,
156
- create_primary_query_index_handler&& handler);
157
- void
158
- initiate_create_primary_query_index(std::shared_ptr<couchbase::core::cluster> core,
159
- std::string bucket_name,
160
- couchbase::create_primary_query_index_options::built options,
161
- create_primary_query_index_handler&& handler);
162
-
163
- #endif
164
- } // namespace impl
165
- } // namespace core
166
137
  } // namespace couchbase
@@ -136,37 +136,4 @@ class create_query_index_options : public common_options<create_query_index_opti
136
136
  */
137
137
 
138
138
  using create_query_index_handler = std::function<void(couchbase::manager_error_context)>;
139
-
140
- #ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
141
- namespace core
142
- {
143
- class cluster;
144
- class query_context;
145
- namespace impl
146
- {
147
-
148
- /**
149
- * @since 1.0.0
150
- * @internal
151
- */
152
- void
153
- initiate_create_query_index(std::shared_ptr<couchbase::core::cluster> core,
154
- std::string bucket_name,
155
- std::string index_name,
156
- std::vector<std::string> fields,
157
- couchbase::create_query_index_options::built options,
158
- create_query_index_handler&& handler);
159
- void
160
- initiate_create_query_index(std::shared_ptr<couchbase::core::cluster> core,
161
- std::string bucket_name,
162
- std::string index_name,
163
- std::vector<std::string> fields,
164
- couchbase::create_query_index_options::built options,
165
- query_context query_ctx,
166
- std::string collection_name,
167
- create_query_index_handler&& handler);
168
-
169
- #endif
170
- } // namespace impl
171
- } // namespace core
172
139
  } // namespace couchbase
@@ -0,0 +1,41 @@
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 <functional>
21
+ #include <memory>
22
+ #include <optional>
23
+ #include <string>
24
+
25
+ namespace couchbase
26
+ {
27
+ struct drop_bucket_options : public common_options<drop_bucket_options> {
28
+ public:
29
+ struct built : public common_options<drop_bucket_options>::built {
30
+ };
31
+
32
+ [[nodiscard]] auto build() const -> built
33
+ {
34
+ return { build_common_options() };
35
+ }
36
+
37
+ private:
38
+ };
39
+
40
+ using drop_bucket_handler = std::function<void(couchbase::manager_error_context)>;
41
+ } // namespace couchbase
@@ -96,34 +96,4 @@ class drop_primary_query_index_options : public common_options<drop_primary_quer
96
96
  */
97
97
 
98
98
  using drop_primary_query_index_handler = std::function<void(couchbase::manager_error_context)>;
99
-
100
- #ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
101
- namespace core
102
- {
103
- class cluster;
104
- class query_context;
105
- namespace impl
106
- {
107
-
108
- /**
109
- * @since 1.0.0
110
- * @internal
111
- */
112
- void
113
- initiate_drop_primary_query_index(std::shared_ptr<couchbase::core::cluster> core,
114
- std::string bucket_name,
115
- couchbase::drop_primary_query_index_options::built options,
116
- query_context query_ctx,
117
- std::string collection_name,
118
- drop_primary_query_index_handler&& handler);
119
-
120
- void
121
- initiate_drop_primary_query_index(std::shared_ptr<couchbase::core::cluster> core,
122
- std::string bucket_name,
123
- couchbase::drop_primary_query_index_options::built options,
124
- drop_primary_query_index_handler&& handler);
125
-
126
- #endif
127
- } // namespace impl
128
- } // namespace core
129
99
  } // namespace couchbase
@@ -82,35 +82,4 @@ class drop_query_index_options : public common_options<drop_query_index_options>
82
82
  */
83
83
 
84
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
85
  } // namespace couchbase
@@ -599,8 +599,7 @@ enum class key_value {
599
599
  // KV Code: 0xd6
600
600
  cannot_revive_living_document = 131,
601
601
 
602
- range_scan_cancelled = 132,
603
- range_scan_vb_uuid_not_equal = 133,
602
+ mutation_token_outdated = 133,
604
603
  range_scan_completed = 134,
605
604
  };
606
605