Expose async state of replace throughput API#4096
Draft
tvaron3 wants to merge 1 commit intoAzure:mainfrom
Draft
Conversation
Rename replace_throughput to begin_replace_throughput on ContainerClient and DatabaseClient, returning a new ThroughputPoller type that detects whether the operation completed synchronously (HTTP 200) or asynchronously (HTTP 202 / x-ms-offer-replace-pending header). ThroughputPoller implements IntoFuture for simple .await usage and Stream for manual polling. It caches the offer RID from the initial response for efficient single-GET polling and propagates the caller Context for distributed tracing. Fixes Azure#3792 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Resolves #3792 — makes
replace_throughputclearly expose the async nature of the Cosmos DB throughput API.The Cosmos DB service may process throughput changes asynchronously (HTTP 202 with
x-ms-offer-replace-pending: true), but the previous API returned a simpleCosmosResponse<ThroughputProperties>with no indication of whether the change was still in-flight.Changes
Renamed
replace_throughput→begin_replace_throughputonContainerClientandDatabaseClientper the Azure SDK LRO naming guideline (begin_prefix for LROs).Added
ThroughputPoller— a custom type that implements bothIntoFuture(simple.await) andStream(manual polling) to handle sync vs async throughput operations:.awaitresolves instantly.x-ms-offer-replace-pending: true: Polls the offer resource at 5-second intervals until the operation completes.Contextthrough polling for distributed tracing.Why not
azure_core::Poller? Cosmos throughput LROs use a header-based detection pattern (x-ms-offer-replace-pending), not theOperation-LocationURL pattern thatazure_core::PollerandStatusMonitorexpect. A custom type follows the Cosmos SDK convention of wrapping azure_core internals (likeCosmosResponsewrapsResponse,FeedItemIteratorwrapsBoxStream).Migration
Testing
container_throughput_high_ru— replaces throughput to 11000 RU/s (may trigger async processing).container_throughput_stream_polling— exercises theStreaminterface directly.ThroughputPollercompleted path andis_offer_replace_pendingheader detection.