Skip to content

Commit

Permalink
RCBC-442: Support query with read from replica (#112)
Browse files Browse the repository at this point in the history
* Updated core
* Added `use_replica` in query options which is mapped to the relevant option in the core API
* FeatureNotAvailable is raised if `use_replica` is not nil and the server does not support query with read from replica
  • Loading branch information
DemetrisChr committed Jul 11, 2023
1 parent 49e372a commit 08a35ed
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ext/couchbase
Submodule couchbase updated 112 files
1 change: 1 addition & 0 deletions ext/couchbase.cxx
Expand Up @@ -3696,6 +3696,7 @@ cb_Backend_document_query(VALUE self, VALUE statement, VALUE options)
cb_extract_option_bool(req.readonly, options, "readonly");
cb_extract_option_bool(req.flex_index, options, "flex_index");
cb_extract_option_bool(req.preserve_expiry, options, "preserve_expiry");
cb_extract_option_bool(req.use_replica, options, "use_replica");
cb_extract_option_uint64(req.scan_cap, options, "scan_cap");
cb_extract_duration(req.scan_wait, options, "scan_wait");
cb_extract_option_uint64(req.max_parallelism, options, "max_parallelism");
Expand Down
6 changes: 6 additions & 0 deletions lib/couchbase/options.rb
Expand Up @@ -1849,6 +1849,7 @@ class Query < Base
attr_accessor :profile # @return [Symbol]
attr_accessor :flex_index # @return [Boolean]
attr_accessor :preserve_expiry # @return [Boolean]
attr_accessor :use_replica # @return [Boolean, nil]
attr_accessor :scope_qualifier # @return [String]
attr_accessor :transcoder # @return [JsonTranscoder, #decode(String)]

Expand Down Expand Up @@ -1894,6 +1895,8 @@ class Query < Base
# @param [Boolean, nil] flex_index Tells the query engine to use a flex index (utilizing the search service)
# @param [Boolean, nil] preserve_expiry Tells the query engine to preserve expiration values set on any documents
# modified by this query.
# @param [Boolean, nil] use_replica Specifies that the query engine should use replica nodes for KV fetches if
# the active node is down. If not provided, the server default will be used
# @param [String, nil] scope_qualifier Associate scope qualifier (also known as +query_context+) with the query.
# The qualifier must be in form +{bucket_name}.{scope_name}+ or +default:{bucket_name}.{scope_name}+.
# @param [JsonTranscoder] transcoder to decode rows
Expand Down Expand Up @@ -1925,6 +1928,7 @@ def initialize(adhoc: true,
profile: :off,
flex_index: nil,
preserve_expiry: nil,
use_replica: nil,
scope_qualifier: nil,
scan_consistency: :not_bounded,
mutation_state: nil,
Expand All @@ -1950,6 +1954,7 @@ def initialize(adhoc: true,
@profile = profile
@flex_index = flex_index
@preserve_expiry = preserve_expiry
@use_replica = use_replica
@scope_qualifier = scope_qualifier
@scan_consistency = scan_consistency
@mutation_state = mutation_state
Expand Down Expand Up @@ -2043,6 +2048,7 @@ def to_backend(scope_name: nil, bucket_name: nil)
readonly: @readonly,
flex_index: @flex_index,
preserve_expiry: @preserve_expiry,
use_replica: @use_replica,
scan_wait: Utils::Time.extract_duration(@scan_wait),
scan_cap: @scan_cap,
pipeline_batch: @pipeline_batch,
Expand Down

0 comments on commit 08a35ed

Please sign in to comment.