Skip to content

Cosmos: Cutover transactional batch operation to Driver#4281

Merged
simorenoh merged 5 commits into
release/azure_data_cosmos-previewsfrom
cutover-batch
Apr 30, 2026
Merged

Cosmos: Cutover transactional batch operation to Driver#4281
simorenoh merged 5 commits into
release/azure_data_cosmos-previewsfrom
cutover-batch

Conversation

@simorenoh

@simorenoh simorenoh commented Apr 27, 2026

Copy link
Copy Markdown
Member

Migrates ContainerClient::execute_transactional_batch() from the legacy CosmosRequest + BatchOptions::apply_headers() + container_connection.send() pipeline to CosmosOperation + driver.execute_operation(), matching the pattern established in #4147, #4174, and #4128.

This was the last item-level operation using the old SDK pipeline for header manipulation, so the batch-specific helpers are removed as dead code.

Changes

azure_data_cosmos_driver/src/models/cosmos_operation.rs

  • Added CosmosOperation::batch() factory (POST to items feed with partition
    key, OperationType::Batch), following the create_item pattern.

azure_data_cosmos/src/clients/container_client.rs

  • Rewrote execute_transactional_batch to build a CosmosOperation::batch,
    apply options, execute through the driver, and bridge the response.
  • Added apply_batch_options helper that takes &BatchOptions and wires
    session token onto the operation.
  • Removed the items_link field from ContainerClient — it was only used by
    the batch method's old CosmosRequest path.

azure_data_cosmos/src/options/mod.rs

  • Removed BatchOptions::apply_headers().
  • Removed the apply_content_response_on_write_header() helper (sole caller
    was BatchOptions::apply_headers).
  • Removed 4 batch header tests that validated the removed methods.
  • Cleaned up unused imports.

azure_data_cosmos/src/constants.rs

  • Removed the PREFER_MINIMAL constant, which is no longer referenced in the
    SDK crate. The driver handles this header internally via its operation pipeline.

@github-actions github-actions Bot added the Cosmos The azure_cosmos crate label Apr 27, 2026
@simorenoh simorenoh linked an issue Apr 27, 2026 that may be closed by this pull request
@simorenoh simorenoh changed the title Cosmos: Port over batch operation to Driver Cosmos: Port over transactional batch operation to Driver Apr 27, 2026
@simorenoh simorenoh changed the title Cosmos: Port over transactional batch operation to Driver Cosmos: Cutover transactional batch operation to Driver Apr 27, 2026
@simorenoh simorenoh marked this pull request as ready for review April 27, 2026 23:52
Copilot AI review requested due to automatic review settings April 27, 2026 23:52
@simorenoh simorenoh requested a review from a team as a code owner April 27, 2026 23:52
@simorenoh

Copy link
Copy Markdown
Member Author

/azp run rust - cosmos - weekly

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates ContainerClient::execute_transactional_batch() to the Cosmos Driver CosmosOperation execution path, aligning transactional batch with other item/query operations that have already been cut over and removing now-dead legacy header shims.

Changes:

  • Add CosmosOperation::batch() factory for transactional batch requests.
  • Route execute_transactional_batch() through driver.execute_operation() and bridge the driver response back to SDK types.
  • Remove legacy SDK batch header helpers/tests and delete now-unused SDK constants/fields.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
sdk/cosmos/azure_data_cosmos_driver/src/models/cosmos_operation.rs Adds a driver-level batch() operation factory targeting the items feed with a partition key.
sdk/cosmos/azure_data_cosmos_driver/src/models/cosmos_headers.rs Introduces request header name constants needed for driver batch request construction.
sdk/cosmos/azure_data_cosmos_driver/src/driver/pipeline/operation_pipeline.rs Emits required batch headers when OperationType::Batch and adds unit tests asserting header behavior.
sdk/cosmos/azure_data_cosmos/src/options/mod.rs Removes legacy BatchOptions::apply_headers() and related helpers/tests now that batch is driver-routed.
sdk/cosmos/azure_data_cosmos/src/constants.rs Removes PREFER_MINIMAL constant (no longer used by the SDK crate after cutover).
sdk/cosmos/azure_data_cosmos/src/clients/container_client.rs Rewrites execute_transactional_batch() to build/execute a driver operation; removes items_link field and adds apply_batch_options.

@simorenoh

Copy link
Copy Markdown
Member Author

/azp run rust - cosmos - weekly

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@analogrelay analogrelay left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Love how straightforward these cutovers have become.

@github-project-automation github-project-automation Bot moved this from Todo to Approved in CosmosDB Rust SDK and Driver Apr 28, 2026
@simorenoh simorenoh merged commit de86fdd into release/azure_data_cosmos-previews Apr 30, 2026
31 checks passed
@github-project-automation github-project-automation Bot moved this from Approved to Done in CosmosDB Rust SDK and Driver Apr 30, 2026
@simorenoh simorenoh deleted the cutover-batch branch April 30, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Cosmos The azure_cosmos crate

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Cosmos: Cutover transactional batch operation to Driver

4 participants