couchbase 3.0.0.alpha.5 → 3.0.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +12 -3
  3. data/README.md +4 -2
  4. data/Rakefile +1 -1
  5. data/couchbase.gemspec +17 -12
  6. data/ext/.idea/misc.xml +12 -0
  7. data/ext/CMakeLists.txt +10 -1
  8. data/ext/build_config.hxx.in +20 -0
  9. data/ext/build_version.hxx.in +1 -1
  10. data/ext/couchbase/bucket.hxx +90 -24
  11. data/ext/couchbase/cluster.hxx +125 -84
  12. data/ext/couchbase/cluster_options.hxx +53 -0
  13. data/ext/couchbase/configuration.hxx +220 -2
  14. data/ext/couchbase/couchbase.cxx +134 -127
  15. data/ext/couchbase/io/dns_client.hxx +3 -1
  16. data/ext/couchbase/io/http_command.hxx +91 -0
  17. data/ext/couchbase/io/http_session.hxx +58 -19
  18. data/ext/couchbase/io/http_session_manager.hxx +26 -31
  19. data/ext/couchbase/io/mcbp_command.hxx +180 -0
  20. data/ext/couchbase/io/mcbp_message.hxx +5 -0
  21. data/ext/couchbase/io/mcbp_session.hxx +213 -98
  22. data/ext/couchbase/io/streams.hxx +165 -0
  23. data/ext/couchbase/operations.hxx +1 -1
  24. data/ext/couchbase/operations/analytics_dataset_create.hxx +1 -1
  25. data/ext/couchbase/operations/bucket_create.hxx +4 -2
  26. data/ext/couchbase/operations/bucket_drop.hxx +4 -2
  27. data/ext/couchbase/operations/bucket_flush.hxx +4 -2
  28. data/ext/couchbase/operations/bucket_get.hxx +4 -2
  29. data/ext/couchbase/operations/bucket_get_all.hxx +4 -2
  30. data/ext/couchbase/operations/bucket_update.hxx +4 -2
  31. data/ext/couchbase/operations/cluster_developer_preview_enable.hxx +4 -2
  32. data/ext/couchbase/operations/collection_create.hxx +4 -2
  33. data/ext/couchbase/operations/collection_drop.hxx +4 -2
  34. data/ext/couchbase/operations/document_analytics.hxx +0 -4
  35. data/ext/couchbase/operations/document_decrement.hxx +6 -3
  36. data/ext/couchbase/operations/document_get.hxx +3 -0
  37. data/ext/couchbase/operations/document_get_and_lock.hxx +3 -0
  38. data/ext/couchbase/operations/document_get_and_touch.hxx +5 -2
  39. data/ext/couchbase/operations/document_get_projected.hxx +12 -9
  40. data/ext/couchbase/operations/document_increment.hxx +6 -3
  41. data/ext/couchbase/operations/document_insert.hxx +5 -2
  42. data/ext/couchbase/operations/document_lookup_in.hxx +3 -0
  43. data/ext/couchbase/operations/document_mutate_in.hxx +6 -3
  44. data/ext/couchbase/operations/document_remove.hxx +3 -0
  45. data/ext/couchbase/operations/document_replace.hxx +5 -2
  46. data/ext/couchbase/operations/document_search.hxx +6 -7
  47. data/ext/couchbase/operations/document_touch.hxx +5 -2
  48. data/ext/couchbase/operations/document_unlock.hxx +3 -0
  49. data/ext/couchbase/operations/document_upsert.hxx +5 -2
  50. data/ext/couchbase/operations/query_index_build_deferred.hxx +3 -3
  51. data/ext/couchbase/operations/query_index_create.hxx +3 -3
  52. data/ext/couchbase/operations/query_index_drop.hxx +3 -3
  53. data/ext/couchbase/operations/query_index_get_all.hxx +3 -3
  54. data/ext/couchbase/operations/scope_create.hxx +4 -2
  55. data/ext/couchbase/operations/scope_drop.hxx +4 -2
  56. data/ext/couchbase/operations/scope_get_all.hxx +4 -2
  57. data/ext/couchbase/operations/search_index_analyze_document.hxx +2 -2
  58. data/ext/couchbase/operations/search_index_control_ingest.hxx +2 -2
  59. data/ext/couchbase/operations/search_index_control_plan_freeze.hxx +2 -2
  60. data/ext/couchbase/operations/search_index_control_query.hxx +2 -2
  61. data/ext/couchbase/operations/search_index_drop.hxx +2 -2
  62. data/ext/couchbase/operations/search_index_get.hxx +2 -2
  63. data/ext/couchbase/operations/search_index_get_all.hxx +2 -2
  64. data/ext/couchbase/operations/search_index_get_documents_count.hxx +2 -2
  65. data/ext/couchbase/operations/search_index_upsert.hxx +2 -2
  66. data/ext/couchbase/origin.hxx +148 -0
  67. data/ext/couchbase/protocol/cmd_cluster_map_change_notification.hxx +1 -6
  68. data/ext/couchbase/protocol/cmd_decrement.hxx +5 -5
  69. data/ext/couchbase/protocol/cmd_get_and_touch.hxx +5 -5
  70. data/ext/couchbase/protocol/cmd_get_cluster_config.hxx +1 -6
  71. data/ext/couchbase/protocol/cmd_increment.hxx +5 -5
  72. data/ext/couchbase/protocol/cmd_info.hxx +0 -11
  73. data/ext/couchbase/protocol/cmd_insert.hxx +5 -5
  74. data/ext/couchbase/protocol/cmd_mutate_in.hxx +6 -6
  75. data/ext/couchbase/protocol/cmd_replace.hxx +5 -5
  76. data/ext/couchbase/protocol/cmd_touch.hxx +1 -1
  77. data/ext/couchbase/protocol/cmd_upsert.hxx +5 -5
  78. data/ext/couchbase/timeout_defaults.hxx +7 -0
  79. data/ext/couchbase/utils/connection_string.hxx +139 -0
  80. data/ext/extconf.rb +44 -11
  81. data/ext/test/main.cxx +93 -15
  82. data/ext/third_party/http_parser/Makefile +160 -0
  83. data/ext/third_party/json/Makefile +77 -0
  84. data/lib/couchbase/analytics_options.rb +18 -4
  85. data/lib/couchbase/binary_collection.rb +2 -2
  86. data/lib/couchbase/binary_collection_options.rb +2 -2
  87. data/lib/couchbase/bucket.rb +4 -4
  88. data/lib/couchbase/cluster.rb +60 -46
  89. data/lib/couchbase/collection.rb +13 -13
  90. data/lib/couchbase/collection_options.rb +15 -9
  91. data/{bin/console → lib/couchbase/datastructures.rb} +4 -7
  92. data/lib/couchbase/datastructures/couchbase_list.rb +171 -0
  93. data/lib/couchbase/datastructures/couchbase_map.rb +205 -0
  94. data/lib/couchbase/datastructures/couchbase_queue.rb +145 -0
  95. data/lib/couchbase/datastructures/couchbase_set.rb +138 -0
  96. data/lib/couchbase/errors.rb +66 -63
  97. data/lib/couchbase/management/user_manager.rb +1 -1
  98. data/lib/couchbase/mutation_state.rb +1 -0
  99. data/lib/couchbase/query_options.rb +25 -2
  100. data/lib/couchbase/scope.rb +0 -7
  101. data/lib/couchbase/search_options.rb +7 -0
  102. data/lib/couchbase/version.rb +1 -1
  103. data/lib/couchbase/view_options.rb +4 -3
  104. metadata +20 -82
  105. data/.github/workflows/tests-6.0.3.yml +0 -52
  106. data/.github/workflows/tests-dev-preview.yml +0 -55
  107. data/.github/workflows/tests.yml +0 -50
  108. data/.gitignore +0 -20
  109. data/.gitmodules +0 -21
  110. data/.idea/.gitignore +0 -5
  111. data/.idea/dictionaries/gem_terms.xml +0 -18
  112. data/.idea/inspectionProfiles/Project_Default.xml +0 -8
  113. data/.idea/vcs.xml +0 -13
  114. data/bin/check-cluster +0 -31
  115. data/bin/fetch-stats +0 -19
  116. data/bin/init-cluster +0 -82
  117. data/bin/jenkins/build-extension +0 -35
  118. data/bin/jenkins/install-dependencies +0 -47
  119. data/bin/jenkins/test-with-cbdyncluster +0 -58
  120. data/bin/setup +0 -24
  121. data/ext/couchbase/configuration_monitor.hxx +0 -93
  122. data/ext/couchbase/operations/command.hxx +0 -163
  123. data/rbi/couchbase.rbi +0 -79
@@ -1,58 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- # Copyright 2020 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
- set -x
18
- set -e
19
-
20
- cbdyncluster info
21
- cbdyncluster ps -a
22
-
23
- CB_VERSION=${CB_VERSION:-6.5.1}
24
- CB_RUBY_VERSION=${CB_RUBY_VERSION:-2.7.1}
25
-
26
- CLUSTER_ID=$(cbdyncluster allocate --num-nodes=3 --server-version=${CB_VERSION})
27
- SERVICES="kv,index,n1ql,fts"
28
- cbdyncluster setup ${CLUSTER_ID} \
29
- --bucket=default \
30
- --enable-developer-preview \
31
- --storage-mode=plasma \
32
- --node=${SERVICES} \
33
- --node=${SERVICES} \
34
- --node=${SERVICES}
35
- sleep 30
36
-
37
- source /usr/local/share/chruby/chruby.sh
38
- chruby ruby-${CB_RUBY_VERSION}
39
-
40
- export COUCHBASE_BACKEND_LOG_LEVEL=debug
41
- # CB_TEST_NAME=test_exists_allows_to_check_document_existence
42
-
43
- if [ ! -z $CB_TEST_NAME ]
44
- then
45
- export TESTOPTS="--name='/^${CB_TEST_NAME}$/'"
46
- fi
47
- export TEST_SERVER_VERSION=${CB_VERSION}
48
- export TEST_DEVELOPER_PREVIEW=yes
49
- export TEST_CONNECTION_STRING=$(cbdyncluster connstr ${CLUSTER_ID})
50
- set +e
51
-
52
- bundle exec rake test
53
- STATUS=$?
54
- set -e
55
-
56
- cbdyncluster rm ${CLUSTER_ID}
57
-
58
- exit ${STATUS}
data/bin/setup DELETED
@@ -1,24 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- # Copyright 2020 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
- PROJECT_ROOT="$( cd "$(dirname "$0"/..)" >/dev/null 2>&1 ; pwd -P )"
18
-
19
- set -euo pipefail
20
- IFS=$'\n\t'
21
- set -vx
22
- git submodule update --init
23
- bundle config set --local path ${PROJECT_ROOT}/vendor/bundle
24
- bundle install
@@ -1,93 +0,0 @@
1
- /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
- /*
3
- * Copyright 2020 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
-
22
- #include <asio.hpp>
23
-
24
- #include <configuration.hxx>
25
-
26
- namespace couchbase
27
- {
28
- class configuration_monitor
29
- {
30
- public:
31
- using listener_type = std::function<void(const configuration& conf)>;
32
-
33
- explicit configuration_monitor(asio::io_context& ctx)
34
- : strand_(ctx.get_executor())
35
- {
36
- }
37
-
38
- void post(configuration&& conf)
39
- {
40
- asio::post(asio::bind_executor(strand_, [this, conf = std::move(conf)]() {
41
- for (auto& listener : listeners_) {
42
- listener.second(conf);
43
- }
44
- }));
45
- }
46
-
47
- void post(const std::string& bucket_name, configuration&& conf)
48
- {
49
- auto& listeners = bucket_listeners_[bucket_name];
50
- if (listeners.empty()) {
51
- return;
52
- }
53
- asio::post(asio::bind_executor(strand_, [&listeners, conf = std::move(conf)]() {
54
- for (auto& listener : listeners) {
55
- listener.second(conf);
56
- }
57
- }));
58
- }
59
-
60
- std::size_t subscribe(listener_type&& listener)
61
- {
62
- auto token = next_token_++;
63
- listeners_[token] = listener;
64
- return token;
65
- }
66
-
67
- std::size_t subscribe(const std::string& bucket_name, listener_type&& listener)
68
- {
69
- auto token = next_token_++;
70
- bucket_listeners_[bucket_name][token] = listener;
71
- return token;
72
- }
73
-
74
- void unsubscribe(size_t token)
75
- {
76
- listeners_.erase(token);
77
- }
78
-
79
- void unsubscribe(const std::string& bucket_name, size_t token)
80
- {
81
- auto b = bucket_listeners_.find(bucket_name);
82
- if (b != bucket_listeners_.end()) {
83
- b->second.erase(token);
84
- }
85
- }
86
-
87
- private:
88
- asio::strand<asio::io_context::executor_type> strand_;
89
- std::map<size_t, listener_type> listeners_;
90
- std::map<std::string, std::map<size_t, listener_type>> bucket_listeners_;
91
- std::size_t next_token_{ 0 };
92
- };
93
- } // namespace couchbase
@@ -1,163 +0,0 @@
1
- /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
- /*
3
- * Copyright 2020 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 <io/mcbp_session.hxx>
21
- #include <io/http_session.hxx>
22
- #include <protocol/cmd_get_collection_id.hxx>
23
-
24
- namespace couchbase::operations
25
- {
26
-
27
- template<typename Request>
28
- struct command : public std::enable_shared_from_this<command<Request>> {
29
- using encoded_request_type = typename Request::encoded_request_type;
30
- using encoded_response_type = typename Request::encoded_response_type;
31
- asio::steady_timer deadline;
32
- asio::steady_timer retry_backoff;
33
- Request request;
34
- encoded_request_type encoded;
35
-
36
- command(asio::io_context& ctx, Request&& req)
37
- : deadline(ctx)
38
- , retry_backoff(ctx)
39
- , request(req)
40
- {
41
- }
42
-
43
- template<typename Handler>
44
- void request_collection_id(std::shared_ptr<io::mcbp_session> session, Handler&& handler)
45
- {
46
- protocol::client_request<protocol::get_collection_id_request_body> req;
47
- req.opaque(session->next_opaque());
48
- req.body().collection_path(request.id.collection);
49
- session->write_and_subscribe(req.opaque(),
50
- req.data(session->supports_feature(protocol::hello_feature::snappy)),
51
- [self = this->shared_from_this(), session, handler = std::forward<Handler>(handler)](
52
- std::error_code ec, io::mcbp_message&& msg) mutable {
53
- if (ec == std::make_error_code(error::common_errc::collection_not_found)) {
54
- if (self->request.id.collection_uid) {
55
- return self->handle_unknown_collection(session, std::forward<Handler>(handler));
56
- }
57
- return handler(make_response(ec, self->request, {}));
58
- }
59
- if (ec) {
60
- return handler(make_response(ec, self->request, {}));
61
- }
62
- protocol::client_response<protocol::get_collection_id_response_body> resp(msg);
63
- session->update_collection_uid(self->request.id.collection, resp.body().collection_uid());
64
- self->request.id.collection_uid = resp.body().collection_uid();
65
- return self->send_to(session, std::forward<Handler>(handler));
66
- });
67
- }
68
-
69
- template<typename Handler>
70
- void handle_unknown_collection(std::shared_ptr<io::mcbp_session> session, Handler&& handler)
71
- {
72
- auto backoff = std::chrono::milliseconds(500);
73
- if (std::chrono::steady_clock::now() + backoff > deadline.expiry()) {
74
- return handler(make_response(std::make_error_code(error::common_errc::ambiguous_timeout), request, {}));
75
- }
76
- retry_backoff.expires_after(backoff);
77
- retry_backoff.async_wait(
78
- [self = this->shared_from_this(), session, handler = std::forward<Handler>(handler)](std::error_code ec) mutable {
79
- if (ec == asio::error::operation_aborted) {
80
- return handler(make_response(std::make_error_code(error::common_errc::ambiguous_timeout), self->request, {}));
81
- }
82
- self->request_collection_id(session, std::forward<Handler>(handler));
83
- });
84
- }
85
-
86
- template<typename Handler>
87
- void send_to(std::shared_ptr<io::mcbp_session> session, Handler&& handler)
88
- {
89
- auto opaque = session->next_opaque();
90
- request.opaque = opaque;
91
- if (!request.id.collection_uid) {
92
- if (session->supports_feature(protocol::hello_feature::collections)) {
93
- auto collection_id = session->get_collection_uid(request.id.collection);
94
- if (collection_id) {
95
- request.id.collection_uid = *collection_id;
96
- } else {
97
- return request_collection_id(session, std::forward<Handler>(handler));
98
- }
99
- } else {
100
- if (!request.id.collection.empty() && request.id.collection != "_default._default") {
101
- return handler(make_response(std::make_error_code(error::common_errc::unsupported_operation), request, {}));
102
- }
103
- }
104
- }
105
- request.encode_to(encoded);
106
- session->write_and_subscribe(
107
- request.opaque,
108
- encoded.data(session->supports_feature(protocol::hello_feature::snappy)),
109
- [self = this->shared_from_this(), session, handler = std::forward<Handler>(handler)](std::error_code ec,
110
- io::mcbp_message&& msg) mutable {
111
- if (ec == asio::error::operation_aborted) {
112
- return handler(make_response(std::make_error_code(error::common_errc::ambiguous_timeout), self->request, {}));
113
- }
114
- self->deadline.cancel();
115
- self->retry_backoff.cancel();
116
- encoded_response_type resp(msg);
117
- if (resp.status() == protocol::status::unknown_collection) {
118
- return self->handle_unknown_collection(session, std::forward<Handler>(handler));
119
- }
120
- handler(make_response(ec, self->request, resp));
121
- });
122
- deadline.expires_after(request.timeout);
123
- deadline.async_wait([session, opaque](std::error_code ec) {
124
- if (ec == asio::error::operation_aborted) {
125
- return;
126
- }
127
- session->cancel(opaque, asio::error::operation_aborted);
128
- });
129
- }
130
-
131
- template<typename Handler>
132
- void send_to(std::shared_ptr<io::http_session> session, Handler&& handler)
133
- {
134
- request.encode_to(encoded);
135
- spdlog::trace("{} HTTP request: {}, method={}, path={}{:a}",
136
- session->log_prefix(),
137
- encoded.type,
138
- encoded.method,
139
- encoded.path,
140
- spdlog::to_hex(encoded.body));
141
- session->write_and_subscribe(encoded,
142
- [self = this->shared_from_this(), session, handler = std::forward<Handler>(handler)](
143
- std::error_code ec, io::http_response&& msg) mutable {
144
- encoded_response_type resp(msg);
145
- self->deadline.cancel();
146
- spdlog::trace("{} HTTP response: {}, status={}{:a}",
147
- session->log_prefix(),
148
- self->request.type,
149
- resp.status_code,
150
- spdlog::to_hex(resp.body));
151
- handler(make_response(ec, self->request, resp));
152
- });
153
- deadline.expires_after(request.timeout);
154
- deadline.async_wait([session](std::error_code ec) {
155
- if (ec == asio::error::operation_aborted) {
156
- return;
157
- }
158
- session->stop();
159
- });
160
- }
161
- };
162
-
163
- } // namespace couchbase::operations
@@ -1,79 +0,0 @@
1
- # Copyright 2020 Couchbase, Inc.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- # typed: strict
16
- module Couchbase
17
- class Cluster
18
- sig {params().returns(UserManager)}
19
- def users
20
- UserManager.new(@io)
21
- end
22
-
23
- sig {params().returns(BucketManager)}
24
- def buckets
25
- BucketManager.new(@io)
26
- end
27
-
28
- sig {params().returns(QueryIndexManager)}
29
- def query_indexes
30
- QueryIndexManager.new(@io)
31
- end
32
-
33
- sig {params().returns(AnalyticsIndexManager)}
34
- def analytics_indexes
35
- AnalyticsIndexManager.new(@io)
36
- end
37
-
38
- sig {params().returns(SearchIndexManager)}
39
- def search_indexes
40
- SearchIndexManager.new(@io)
41
- end
42
- end
43
-
44
- class UserManager
45
- sig {params(io: Backend::IoCore).void}
46
- def initialize(io)
47
- end
48
- end
49
-
50
- class BucketManager
51
- sig {params(io: Backend::IoCore).void}
52
- def initialize(io)
53
- end
54
- end
55
-
56
- class QueryIndexManager
57
- sig {params(io: Backend::IoCore).void}
58
- def initialize(io)
59
- end
60
- end
61
-
62
- class AnalyticsIndexManager
63
- sig {params(io: Backend::IoCore).void}
64
- def initialize(io)
65
- end
66
- end
67
-
68
- class SearchIndexManager
69
- sig {params(io: Backend::IoCore).void}
70
- def initialize(io)
71
- end
72
- end
73
-
74
- # private
75
- module Backend
76
- class IoCore
77
- end
78
- end
79
- end