Skip to content

Cosmos: Transaction Batch Support #2644

@analogrelay

Description

@analogrelay

Feature Summary

Add support for calling the Cosmos Transaction Batch APIs

Feature Description

The Rust SDK doesn't have support for the Transactional Batch APIs yet. We need to add it. The Go SDK would be a good reference for how to implement this: https://github.com/Azure/azure-sdk-for-go/blob/sdk/data/azcosmos/v1.4.0/sdk/data/azcosmos/cosmos_container.go#L622

For Rust, I don't see a reason why the "New Transaction Batch" API needs to live on the ContainerClient. It does in Go but it's just a constructor and doesn't actually use anything from the ContainerClient. Instead, I'd expect an API like this:

let batch = TransactionalBatch::new(partition_key) // Create a batch
  .create_item(...) // Add a "create" to the batch
  .delete_item(...) // Add a "delete" to the batch
  // etc...
container.execute_transactional_batch(batch); // Execute the batch

The ContainerClient::execute_transactional_batch function would then encode all the captured operations into the appropriate JSON payload and call the REST API to execute the batch.

Use Case

No response

Alternatives

No response

Additional Context

No response

Metadata

Metadata

Assignees

Labels

CosmosThe azure_cosmos crate

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions