Skip to content

Commit

Permalink
Fix feature not available exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt-Woz committed Jul 28, 2023
1 parent 8deaf53 commit e13eb49
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
4 changes: 4 additions & 0 deletions core/impl/lookup_in_all_replicas.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ initiate_lookup_in_all_replicas_operation(std::shared_ptr<cluster> core,
core->with_bucket_configuration(
bucket_name,
[core, r = std::move(request), h = std::move(handler)](std::error_code ec, const core::topology::configuration& config) mutable {
if (!config.supports_subdoc_read_replica()) {
ec = errc::common::feature_not_available;
}

if (ec) {
std::optional<std::string> first_error_path{};
std::optional<std::size_t> first_error_index{};
Expand Down
3 changes: 3 additions & 0 deletions core/impl/lookup_in_any_replica.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ initiate_lookup_in_any_replica_operation(std::shared_ptr<cluster> core,
core->with_bucket_configuration(
bucket_name,
[core, r = std::move(request), h = std::move(handler)](std::error_code ec, const core::topology::configuration& config) mutable {
if (!config.supports_subdoc_read_replica()) {
ec = errc::common::feature_not_available;
}
if (ec) {
std::optional<std::string> first_error_path{};
std::optional<std::size_t> first_error_index{};
Expand Down
5 changes: 1 addition & 4 deletions core/impl/lookup_in_replica.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@
namespace couchbase::core::impl
{
std::error_code
lookup_in_replica_request::encode_to(lookup_in_replica_request::encoded_request_type& encoded, mcbp_context&& context)
lookup_in_replica_request::encode_to(lookup_in_replica_request::encoded_request_type& encoded, mcbp_context&& /* context */)
{
if (!context.config->supports_subdoc_read_replica()) {
return errc::common::feature_not_available;
}
for (std::size_t i = 0; i < specs.size(); ++i) {
specs[i].original_index_ = i;
}
Expand Down
4 changes: 4 additions & 0 deletions core/operations/document_lookup_in_all_replicas.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ struct lookup_in_all_replicas_request {
id.bucket(),
[core, id = id, timeout = timeout, specs = specs, parent_span = parent_span, h = std::forward<Handler>(handler)](
std::error_code ec, const topology::configuration& config) mutable {
if (!config.supports_subdoc_read_replica()) {
ec = errc::common::feature_not_available;
}

if (ec) {
std::optional<std::string> first_error_path{};
std::optional<std::size_t> first_error_index{};
Expand Down
4 changes: 4 additions & 0 deletions core/operations/document_lookup_in_any_replica.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ struct lookup_in_any_replica_request {
id.bucket(),
[core, id = id, timeout = timeout, specs = specs, parent_span = parent_span, h = std::forward<Handler>(handler)](
std::error_code ec, const topology::configuration& config) mutable {
if (!config.supports_subdoc_read_replica()) {
ec = errc::common::feature_not_available;
}

if (ec) {
std::optional<std::string> first_error_path{};
std::optional<std::size_t> first_error_index{};
Expand Down

0 comments on commit e13eb49

Please sign in to comment.