-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Added Priority Based Execution for Sync and Async Clients #43917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Added Priority Based Execution for Sync and Async Clients #43917
Conversation
There was a problem hiding this comment.
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 adds client-level priority configuration for Azure Cosmos DB clients (both sync and async), allowing users to set a default priority level for all requests made by a client. This complements the existing request-level priority feature, with request-level priority taking precedence when both are set.
- Added
priority_levelparameter toCosmosClientconstructors in both sync and async implementations - Client-level priority is stored in default headers and applied to all requests
- Comprehensive documentation and examples demonstrating client-level priority, request-level priority, and precedence behavior
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/cosmos/azure-cosmos/azure/cosmos/_cosmos_client_connection.py | Implements client-level priority by adding priority_level parameter and storing it in default_headers |
| sdk/cosmos/azure-cosmos/azure/cosmos/aio/_cosmos_client_connection_async.py | Async implementation of client-level priority, mirroring the sync implementation |
| sdk/cosmos/azure-cosmos/tests/test_headers.py | Adds tests for client-level priority and request-level precedence in sync client |
| sdk/cosmos/azure-cosmos/tests/test_headers_async.py | Adds tests for client-level priority and request-level precedence in async client |
| sdk/cosmos/azure-cosmos/samples/examples.py | Demonstrates client-level priority usage and precedence with practical examples |
| sdk/cosmos/azure-cosmos/samples/examples_async.py | Demonstrates async client-level priority usage and precedence with practical examples |
|
/azp run python - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run python - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
simorenoh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small comments but overall the changes seem to be good, thanks Andrew!
sdk/cosmos/azure-cosmos/azure/cosmos/_cosmos_client_connection.py
Outdated
Show resolved
Hide resolved
|
/azp run python - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Co-authored-by: Simon Moreno <30335873+simorenoh@users.noreply.github.com>
|
/azp run python - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Description
Priority-based execution is a capability which allows users to specify priority for the request sent to Azure Cosmos DB. Based on the priority specified by the user, if there are more requests than the configured RU/s in a second, then Azure Cosmos DB will throttle low priority requests to allow high priority requests to execute. Previously this was only available at the request level now entire clients can be set to a low or high priority level. The request priority level will take precedence over the client priority level in case both are set.