couchbase 3.4.4 → 3.4.5

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 (56) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/ext/couchbase/CMakeLists.txt +7 -0
  4. data/ext/couchbase/core/cluster.hxx +7 -0
  5. data/ext/couchbase/core/impl/create_bucket.cxx +3 -0
  6. data/ext/couchbase/core/impl/create_collection.cxx +83 -0
  7. data/ext/couchbase/core/impl/create_scope.cxx +69 -0
  8. data/ext/couchbase/core/impl/drop_collection.cxx +76 -0
  9. data/ext/couchbase/core/impl/drop_scope.cxx +68 -0
  10. data/ext/couchbase/core/impl/get_all_buckets.cxx +19 -4
  11. data/ext/couchbase/core/impl/get_all_scopes.cxx +94 -0
  12. data/ext/couchbase/core/impl/get_bucket.cxx +19 -4
  13. data/ext/couchbase/core/impl/lookup_in_all_replicas.cxx +2 -0
  14. data/ext/couchbase/core/impl/lookup_in_any_replica.cxx +2 -0
  15. data/ext/couchbase/core/impl/lookup_in_replica.cxx +8 -1
  16. data/ext/couchbase/core/impl/update_bucket.cxx +3 -0
  17. data/ext/couchbase/core/impl/update_collection.cxx +83 -0
  18. data/ext/couchbase/core/management/bucket_settings.hxx +8 -5
  19. data/ext/couchbase/core/management/bucket_settings_json.hxx +12 -2
  20. data/ext/couchbase/core/meta/features.hxx +17 -0
  21. data/ext/couchbase/core/operations/document_lookup_in.cxx +8 -1
  22. data/ext/couchbase/core/operations/management/CMakeLists.txt +1 -0
  23. data/ext/couchbase/core/operations/management/bucket_create.cxx +30 -9
  24. data/ext/couchbase/core/operations/management/bucket_update.cxx +27 -6
  25. data/ext/couchbase/core/operations/management/collection_create.cxx +5 -1
  26. data/ext/couchbase/core/operations/management/collection_create.hxx +1 -0
  27. data/ext/couchbase/core/operations/management/collection_update.cxx +87 -0
  28. data/ext/couchbase/core/operations/management/collection_update.hxx +54 -0
  29. data/ext/couchbase/core/operations/management/collections.hxx +1 -0
  30. data/ext/couchbase/core/timeout_defaults.hxx +1 -1
  31. data/ext/couchbase/core/topology/capabilities.hxx +1 -0
  32. data/ext/couchbase/core/topology/capabilities_fmt.hxx +3 -0
  33. data/ext/couchbase/core/topology/collections_manifest.hxx +2 -0
  34. data/ext/couchbase/core/topology/collections_manifest_json.hxx +3 -0
  35. data/ext/couchbase/core/topology/configuration.hxx +5 -0
  36. data/ext/couchbase/core/topology/configuration_json.hxx +2 -0
  37. data/ext/couchbase/couchbase/bucket.hxx +14 -0
  38. data/ext/couchbase/couchbase/collection_manager.hxx +160 -0
  39. data/ext/couchbase/couchbase/create_collection_options.hxx +44 -0
  40. data/ext/couchbase/couchbase/create_scope_options.hxx +41 -0
  41. data/ext/couchbase/couchbase/drop_collection_options.hxx +41 -0
  42. data/ext/couchbase/couchbase/drop_scope_options.hxx +41 -0
  43. data/ext/couchbase/couchbase/get_all_scopes_options.hxx +44 -0
  44. data/ext/couchbase/couchbase/management/bucket_settings.hxx +8 -5
  45. data/ext/couchbase/couchbase/management/collection_spec.hxx +29 -0
  46. data/ext/couchbase/couchbase/management/scope_spec.hxx +29 -0
  47. data/ext/couchbase/couchbase/update_collection_options.hxx +44 -0
  48. data/ext/couchbase/test/test_integration_management.cxx +305 -48
  49. data/ext/couchbase/test/test_integration_subdoc.cxx +81 -22
  50. data/ext/couchbase.cxx +155 -34
  51. data/ext/revisions.rb +3 -3
  52. data/lib/couchbase/collection_options.rb +1 -2
  53. data/lib/couchbase/management/bucket_manager.rb +22 -15
  54. data/lib/couchbase/management/collection_manager.rb +158 -9
  55. data/lib/couchbase/version.rb +1 -1
  56. metadata +23 -6
@@ -0,0 +1,160 @@
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_collection_options.hxx>
21
+ #include <couchbase/create_scope_options.hxx>
22
+ #include <couchbase/drop_collection_options.hxx>
23
+ #include <couchbase/drop_scope_options.hxx>
24
+ #include <couchbase/get_all_scopes_options.hxx>
25
+ #include <couchbase/management/collection_spec.hxx>
26
+ #include <couchbase/update_collection_options.hxx>
27
+
28
+ #include <future>
29
+ #include <memory>
30
+
31
+ #ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
32
+ namespace couchbase::core
33
+ {
34
+ class cluster;
35
+ } // namespace couchbase::core
36
+ #endif
37
+
38
+ namespace couchbase
39
+ {
40
+ class bucket;
41
+
42
+ class collection_manager
43
+ {
44
+ public:
45
+ /**
46
+ * Get all scopes on the bucket
47
+ *
48
+ * @param options optional parameters
49
+ * @param handler handler that implements @ref get_all_scopes_handler
50
+ *
51
+ * @since 1.0.0
52
+ */
53
+ void get_all_scopes(const get_all_scopes_options& options, get_all_scopes_handler&& handler) const;
54
+
55
+ [[nodiscard]] auto get_all_scopes(const get_all_scopes_options& options = {}) const
56
+ -> std::future<std::pair<manager_error_context, std::vector<management::bucket::scope_spec>>>;
57
+
58
+ /**
59
+ * Creates a new collection
60
+ *
61
+ * @param scope_name the name of the scope to create the collection on
62
+ * @param collection_name the collection name
63
+ * @param settings create collection settings
64
+ * @param options optional parameters
65
+ * @param handler handler that implements @ref create_collection_handler
66
+ *
67
+ * @since 1.0.0
68
+ */
69
+ void create_collection(std::string scope_name,
70
+ std::string collection_name,
71
+ const create_collection_settings& settings,
72
+ const create_collection_options& options,
73
+ create_collection_handler&& handler) const;
74
+
75
+ [[nodiscard]] auto create_collection(std::string scope_name,
76
+ std::string collection_name,
77
+ const create_collection_settings& settings = {},
78
+ const create_collection_options& options = {}) const -> std::future<manager_error_context>;
79
+ /**
80
+ * Updates an existing collection
81
+ *
82
+ * @param scope_name the name of the scope on which the collection exists
83
+ * @param collection_name the collection name
84
+ * @param settings update collection settings
85
+ * @param options optional parameters
86
+ * @param handler handler that implements @ref update_collection_handler
87
+ *
88
+ * @since 1.0.0
89
+ */
90
+ void update_collection(std::string scope_name,
91
+ std::string collection_name,
92
+ const update_collection_settings& settings,
93
+ const update_collection_options& options,
94
+ update_collection_handler&& handler) const;
95
+
96
+ [[nodiscard]] auto update_collection(std::string scope_name,
97
+ std::string collection_name,
98
+ const update_collection_settings& settings,
99
+ const update_collection_options& options = {}) const -> std::future<manager_error_context>;
100
+
101
+ /**
102
+ * Drops a collection
103
+ *
104
+ * @param scope_name the name of the scope on which the collection exists
105
+ * @param collection_name the collection name
106
+ * @param options optional parameters
107
+ * @param handler handler that implements @ref drop_collection_handler
108
+ *
109
+ * @since 1.0.0
110
+ */
111
+ void drop_collection(std::string scope_name,
112
+ std::string collection_name,
113
+ const drop_collection_options& options,
114
+ drop_collection_handler&& handler) const;
115
+
116
+ [[nodiscard]] auto drop_collection(std::string scope_name,
117
+ std::string collection_name,
118
+ const drop_collection_options& options = {}) const -> std::future<manager_error_context>;
119
+
120
+ /**
121
+ * Creates a scope on the bucket
122
+ *
123
+ * @param scope_name the scope name
124
+ * @param options optional parameters
125
+ * @param handler handler that implements @ref create_scope_handler
126
+ *
127
+ * @since 1.0.0
128
+ */
129
+ void create_scope(std::string scope_name, const create_scope_options& options, create_scope_handler&& handler) const;
130
+
131
+ [[nodiscard]] auto create_scope(std::string scope_name, const create_scope_options& options = {}) const
132
+ -> std::future<manager_error_context>;
133
+
134
+ /**
135
+ * Drops a scope on the bucket
136
+ *
137
+ * @param scope_name the scope name
138
+ * @param options optional parameters
139
+ * @param handler handler that implements @ref drop_scope_handler
140
+ *
141
+ * @since 1.0.0
142
+ */
143
+ void drop_scope(std::string scope_name, const drop_scope_options& options, drop_scope_handler&& handler) const;
144
+
145
+ [[nodiscard]] auto drop_scope(std::string scope_name, const drop_scope_options& options = {}) const
146
+ -> std::future<manager_error_context>;
147
+
148
+ private:
149
+ friend class bucket;
150
+
151
+ explicit collection_manager(std::shared_ptr<couchbase::core::cluster> core, std::string bucket_name)
152
+ : core_(std::move(core))
153
+ , bucket_name_(std::move(bucket_name))
154
+ {
155
+ }
156
+
157
+ std::shared_ptr<couchbase::core::cluster> core_;
158
+ std::string bucket_name_;
159
+ };
160
+ } // namespace couchbase
@@ -0,0 +1,44 @@
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_collection_options : public common_options<create_collection_options> {
28
+ public:
29
+ struct built : public common_options<create_collection_options>::built {
30
+ };
31
+
32
+ [[nodiscard]] auto build() const -> built
33
+ {
34
+ return { build_common_options() };
35
+ }
36
+ };
37
+
38
+ struct create_collection_settings {
39
+ std::uint32_t max_expiry{ 0 };
40
+ std::optional<bool> history{};
41
+ };
42
+
43
+ using create_collection_handler = std::function<void(couchbase::manager_error_context)>;
44
+ } // 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 create_scope_options : public common_options<create_scope_options> {
28
+ public:
29
+ struct built : public common_options<create_scope_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_scope_handler = std::function<void(couchbase::manager_error_context)>;
41
+ } // 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_collection_options : public common_options<drop_collection_options> {
28
+ public:
29
+ struct built : public common_options<drop_collection_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_collection_handler = std::function<void(couchbase::manager_error_context)>;
41
+ } // 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_scope_options : public common_options<drop_scope_options> {
28
+ public:
29
+ struct built : public common_options<drop_scope_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_scope_handler = std::function<void(couchbase::manager_error_context)>;
41
+ } // namespace couchbase
@@ -0,0 +1,44 @@
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/management/scope_spec.hxx>
21
+
22
+ #include <functional>
23
+ #include <memory>
24
+ #include <optional>
25
+ #include <string>
26
+
27
+ namespace couchbase
28
+ {
29
+ struct get_all_scopes_options : public common_options<get_all_scopes_options> {
30
+ public:
31
+ struct built : public common_options<get_all_scopes_options>::built {
32
+ };
33
+
34
+ [[nodiscard]] auto build() const -> built
35
+ {
36
+ return { build_common_options() };
37
+ }
38
+
39
+ private:
40
+ };
41
+
42
+ using get_all_scopes_handler =
43
+ std::function<void(couchbase::manager_error_context, std::vector<couchbase::management::bucket::scope_spec>)>;
44
+ } // namespace couchbase
@@ -98,15 +98,18 @@ struct bucket_settings {
98
98
 
99
99
  std::string name;
100
100
  cluster::bucket_type bucket_type{ cluster::bucket_type::unknown };
101
- std::uint64_t ram_quota_mb{ 100 };
102
- std::uint32_t max_expiry{ 0 };
101
+ std::uint64_t ram_quota_mb{ 0 };
102
+ std::optional<std::uint32_t> max_expiry{};
103
103
  bucket_compression compression_mode{ bucket_compression::unknown };
104
104
  std::optional<couchbase::durability_level> minimum_durability_level{};
105
- std::uint32_t num_replicas{ 1 };
106
- bool replica_indexes{ false };
107
- bool flush_enabled{ false };
105
+ std::optional<std::uint32_t> num_replicas{};
106
+ std::optional<bool> replica_indexes{};
107
+ std::optional<bool> flush_enabled{};
108
108
  bucket_eviction_policy eviction_policy{ bucket_eviction_policy::unknown };
109
109
  bucket_conflict_resolution conflict_resolution_type{ bucket_conflict_resolution::unknown };
110
+ std::optional<bool> history_retention_collection_default{};
111
+ std::optional<std::uint32_t> history_retention_bytes;
112
+ std::optional<std::uint32_t> history_retention_duration{};
110
113
 
111
114
  /**
112
115
  * UNCOMMITTED: This API may change in the future
@@ -0,0 +1,29 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2020-2021 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
+ namespace couchbase::management::bucket
21
+ {
22
+ struct collection_spec {
23
+ std::string name;
24
+ std::string scope_name;
25
+ std::uint32_t max_expiry{};
26
+ std::optional<bool> history{};
27
+ };
28
+
29
+ } // namespace couchbase::management::bucket
@@ -0,0 +1,29 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2020-2021 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/management/collection_spec.hxx>
21
+
22
+ namespace couchbase::management::bucket
23
+ {
24
+ struct scope_spec {
25
+ std::string name;
26
+ std::vector<collection_spec> collections;
27
+ };
28
+
29
+ } // namespace couchbase::management::bucket
@@ -0,0 +1,44 @@
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 update_collection_options : public common_options<update_collection_options> {
28
+ public:
29
+ struct built : public common_options<update_collection_options>::built {
30
+ };
31
+
32
+ [[nodiscard]] auto build() const -> built
33
+ {
34
+ return { build_common_options() };
35
+ }
36
+ };
37
+
38
+ struct update_collection_settings {
39
+ std::optional<std::uint32_t> max_expiry{};
40
+ std::optional<bool> history{};
41
+ };
42
+
43
+ using update_collection_handler = std::function<void(couchbase::manager_error_context)>;
44
+ } // namespace couchbase