Skip to content

RSCBC-302: Replica read from specific replica - #503

Open
Matt-Woz wants to merge 1 commit into
mainfrom
get_replica
Open

RSCBC-302: Replica read from specific replica#503
Matt-Woz wants to merge 1 commit into
mainfrom
get_replica

Conversation

@Matt-Woz

@Matt-Woz Matt-Woz commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

It introduces new public APIs where at least one is missing rustdoc and one new core options type doesn’t follow established option-type attributes, creating avoidable public-API inconsistency.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR adds end-to-end support for reading documents from a specific replica, including an SDK-facing strategy API, new result/options types, core KV/memdx plumbing, retry/wrap behavior, and performer/protocol integrations.

Changes:

  • Introduces Collection::get_replica with GetReplicaStrategy/ReplicaIndex and GetReplicaResult/GetReplicaOptions in the SDK layer.
  • Implements replica routing + wrap logic in couchbase-core, including new memdx opcode/request/response and helper logic to advance across replicas.
  • Extends error modeling and performer mappings to represent replica-specific error cases and capabilities.
File summaries
File Description
sdk/couchbase/src/results/kv_results.rs Adds GetReplicaResult SDK result type with decoding helpers and core-result conversion.
sdk/couchbase/src/options/kv_options.rs Adds GetReplicaOptions for SDK-level configuration (retry strategy).
sdk/couchbase/src/lib.rs Exposes get_replica_strategy module publicly.
sdk/couchbase/src/get_replica_strategy.rs Adds public strategy API for selecting a replica by index (with optional wrapping).
sdk/couchbase/src/error.rs Adds replica-specific error kinds and maps core errors into SDK errors (including replica-not-found).
sdk/couchbase/src/collection_crud.rs Adds Collection::get_replica operation wired through tracing + core client.
sdk/couchbase/src/clients/couchbase_core_kv_client.rs Translates SDK strategy/options into core agent call and converts the result type.
sdk/couchbase/src/clients/core_kv_client.rs Exposes get_replica across backend variants (core + couchbase2 stub).
sdk/couchbase-core/src/vbucketrouter.rs Propagates replica index/topology info into NoServerAssigned and adds wrap test coverage.
sdk/couchbase-core/src/vbucketmap.rs Fixes replica index bounds check and adds tests for valid/invalid positions.
sdk/couchbase-core/src/retry.rs Refactors retry decision logic into reusable retry_after_error helper.
sdk/couchbase-core/src/results/kv.rs Adds GetReplicaResult at core results level.
sdk/couchbase-core/src/replica_helpers.rs Adds wrap/advance logic for replica selection and comprehensive unit tests.
sdk/couchbase-core/src/options/crud.rs Adds core GetReplicaOptions and GetReplicaStrategy used by the agent/crudcomponent.
sdk/couchbase-core/src/memdx/response.rs Adds GetReplicaResponse decoding and tracing attributes.
sdk/couchbase-core/src/memdx/request.rs Adds GetReplicaRequest request model.
sdk/couchbase-core/src/memdx/ops_crud.rs Implements memdx CRUD operation for GetReplica.
sdk/couchbase-core/src/memdx/opcode.rs Adds memdx opcode mapping for GetReplica (0x83).
sdk/couchbase-core/src/lib.rs Registers internal replica_helpers module.
sdk/couchbase-core/src/kvclient_ops.rs Adds get_replica to KV client ops trait and implementation.
sdk/couchbase-core/src/error.rs Extends NoServerAssigned context and tracks is_replica on memdx errors.
sdk/couchbase-core/src/crudcomponent.rs Implements core get_replica orchestration, routing, wrapping, and retry integration.
sdk/couchbase-core/src/agent_ops.rs Exposes Agent::get_replica operation with optional top-level spans.
performer/src/translations/kv_options.rs Adds proto→SDK translations for GetReplicaOptions and GetReplicaStrategy.
performer/src/translations/common.rs Maps new SDK error kinds to corresponding proto exception types.
performer/src/performer.rs Advertises SdkGetReplica capability.
performer/src/common/content.rs Enables content decoding for GetReplicaResult via existing decoder abstraction.
performer/src/commands/sdk.rs Adds command building/plumbing for the new GetReplica operation + transcoder support.
performer/src/commands/kv.rs Adds GetReplicaCommand execution and result-to-proto mapping.
Review details
  • Files reviewed: 29/29 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +57 to +63
pub struct GetReplicaOptions<'a> {
pub key: &'a [u8],
pub scope_name: &'a str,
pub collection_name: &'a str,
pub strategy: GetReplicaStrategy,
pub retry_strategy: Arc<dyn RetryStrategy>,
}
Comment on lines +362 to +367
pub async fn get_replica(
&self,
id: impl AsRef<str>,
strategy: impl Into<GetReplicaStrategy>,
options: impl Into<Option<GetReplicaOptions>>,
) -> crate::error::Result<GetReplicaResult> {
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

🐰 Bencher Report

Projectcouchbase-rs
Branchget_replica-33888600930-202-1
Testbedubuntu-latest

🚨 1 Alert

BenchmarkMeasure
Units
ViewBenchmark Result
(Result Δ%)
Upper Boundary
(Limit %)
upsert_and_getLatency
microseconds (µs)
📈 plot
🚷 threshold
🚨 alert (🔔)
454.22 µs
(+16.39%)Baseline: 390.25 µs
448.79 µs
(101.21%)

Click to view all benchmark results
BenchmarkLatencyBenchmark Result
microseconds (µs)
(Result Δ%)
Upper Boundary
microseconds (µs)
(Limit %)
query📈 view plot
🚷 view threshold
441.17 µs
(+5.16%)Baseline: 419.54 µs
482.47 µs
(91.44%)
upsert_and_get📈 view plot
🚷 view threshold
🚨 view alert (🔔)
454.22 µs
(+16.39%)Baseline: 390.25 µs
448.79 µs
(101.21%)

🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

🐰 Bencher Report

Projectcouchbase-rs
Branchget_replica-33888600930-202-2
Testbedubuntu-latest
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
microseconds (µs)
(Result Δ%)
Upper Boundary
microseconds (µs)
(Limit %)
query📈 view plot
🚷 view threshold
443.97 µs
(+5.82%)Baseline: 419.54 µs
482.47 µs
(92.02%)
upsert_and_get📈 view plot
🚷 view threshold
430.01 µs
(+10.19%)Baseline: 390.25 µs
448.79 µs
(95.82%)
🐰 View full continuous benchmarking report in Bencher

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants