Skip to content

Commit a69cdd6

Browse files
committed
PYCBC-1675: Forward append/prepend CAS to core request
Motivation ========== Previously the append and prepend requests in the C++ core did not have a field for CAS. This meant that the relevant option in AppendOptions/PrependOptions was being ignored. Changes ======= * Update C++ core & make some changes in response to API changes of the core's with_bucket_configuration() method. * Set the CAS option in the core's append_request & prepend_request. Results ======= Relevant tests in FIT pass. Change-Id: Iea541e43a6807500fdb54ce2335269a236a647f5 Reviewed-on: https://review.couchbase.org/c/couchbase-python-client/+/225076 Tested-by: Build Bot <build@couchbase.com> Reviewed-by: Jared Casey <jared.casey@couchbase.com>
1 parent caf7794 commit a69cdd6

3 files changed

Lines changed: 11 additions & 17 deletions

File tree

deps/couchbase-cxx-client

src/binary_ops.cxx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,7 @@ prepare_and_execute_binary_mutation_op(struct binary_mutation_options* options,
331331
if (options->op_type == Operations::APPEND) {
332332
auto req = couchbase::core::operations::append_request{ options->id };
333333
req.timeout = options->timeout_ms;
334-
// @TODO: cxx client req doesn't have cas
335-
// req.cas = options->cas;
334+
req.cas = options->cas;
336335
req.value = value;
337336
if (nullptr != options->span) {
338337
req.parent_span = std::make_shared<pycbc::request_span>(options->span);
@@ -355,8 +354,7 @@ prepare_and_execute_binary_mutation_op(struct binary_mutation_options* options,
355354
} else {
356355
auto req = couchbase::core::operations::prepend_request{ options->id };
357356
req.timeout = options->timeout_ms;
358-
// @TODO: cxx client req doesn't have cas
359-
// req.cas = options->cas;
357+
req.cas = options->cas;
360358
req.value = value;
361359
if (nullptr != options->span) {
362360
req.parent_span = std::make_shared<pycbc::request_span>(options->span);

src/kv_range_scan.cxx

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -198,19 +198,15 @@ handle_kv_range_scan_op([[maybe_unused]] PyObject* self, PyObject* args, PyObjec
198198
return nullptr;
199199
}
200200

201-
auto barrier = std::make_shared<
202-
std::promise<tl::expected<couchbase::core::topology::configuration, std::error_code>>>();
201+
auto barrier = std::make_shared<std::promise<
202+
std::pair<std::error_code, std::shared_ptr<couchbase::core::topology::configuration>>>>();
203203
auto f = barrier->get_future();
204-
conn->cluster_.with_bucket_configuration(
205-
bucket_name,
206-
[barrier](std::error_code ec, const couchbase::core::topology::configuration& config) mutable {
207-
if (ec) {
208-
return barrier->set_value(tl::unexpected(ec));
209-
}
210-
barrier->set_value(config);
211-
});
212-
auto config = f.get();
213-
if (!config.has_value()) {
204+
conn->cluster_.with_bucket_configuration(bucket_name,
205+
[barrier](std::error_code ec, auto config) mutable {
206+
barrier->set_value({ ec, std::move(config) });
207+
});
208+
auto [ec, config] = f.get();
209+
if (ec) {
214210
pycbc_set_python_exception(
215211
PycbcError::UnsuccessfulOperation,
216212
__FILE__,

0 commit comments

Comments
 (0)