Skip to content

Go v2: expose latest-committed read consistency across the FFI boundary #27351

Description

@tvaron3

Part of the Cosmos DB Go SDK v2 (azcosmos/v2) effort, which binds the Go data plane to the shared Rust Cosmos driver over the C ABI (decision: #27238).

The gap

ReadConsistencyStrategy::LatestCommitted is reachable from the Rust SDK but cannot cross the C ABI, so it cannot be offered by any SDK bound through the native layer — Go included.

The driver defines it:

// azure_data_cosmos_driver/src/options/read_consistency.rs
pub enum ReadConsistencyStrategy {
    Default,
    Eventual,
    Session,
    LatestCommitted,
    GlobalStrong,
}

and the Rust SDK re-exports the enum wholesale, so it is on that SDK's public surface:

// azure_data_cosmos/src/options/mod.rs
pub use azure_data_cosmos_driver::options::{
    ..., ReadConsistencyStrategy, Region, ...
};

But the C ABI's mirror of the enum has no discriminant for it:

COSMOS_READ_CONSISTENCY_STRATEGY_UNSET        = 0,   /* inherit                      */
COSMOS_READ_CONSISTENCY_STRATEGY_DEFAULT      = 1,
COSMOS_READ_CONSISTENCY_STRATEGY_EVENTUAL     = 2,
COSMOS_READ_CONSISTENCY_STRATEGY_SESSION      = 3,
COSMOS_READ_CONSISTENCY_STRATEGY_GLOBAL_STRONG = 4,

So a Rust application can request latest-committed reads and a Go one cannot, purely because of where the boundary sits.

Why it matters

This is a cross-SDK parity gap rather than a Go omission. Any SDK bound through azure_data_cosmos_driver_native — Go, and the .NET/Java/Python bindings that follow — inherits it. Go v2's ReadConsistencyStrategy currently covers all five ABI values and stops there.

What needs deciding

One of two things, and it is the driver crew's call which:

  1. Add a discriminant for latest-committed to CosmosReadConsistencyStrategy in the C ABI, so bound SDKs can express it. This is the option that closes the gap.
  2. Stop re-exporting it from the Rust SDK, if it was never meant to be public there. The wholesale pub use of the driver enum suggests its exposure may be incidental rather than deliberate.

Worth confirming which was intended before Go v2's API is signed off (#27306), since the answer determines whether the Go surface is complete or knowingly short by one value.

References

  • Go v2 surface: sdk/data/azcosmos/read_consistency_strategy.go
  • Header read at Azure/azure-sdk-for-rust commit a080bf7511

Metadata

Metadata

Assignees

No one assigned

    Labels

    ClientThis issue points to a problem in the data-plane of the library.Cosmos

    Type

    No type

    Projects

    Status
    Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions