-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add excluded locations on client and request levels #40022
base: main
Are you sure you want to change the base?
Add excluded locations on client and request levels #40022
Conversation
API change check APIView has identified API level changes in this PR and created following API reviews. |
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 pull request adds support for specifying excluded locations at both the client and request levels, ensuring that the Cosmos DB SDK can properly filter preferred locations when excluded regions are defined. Key changes include:
- New sample functions and updated documentation in the samples module demonstrating how to set excluded locations.
- Modifications throughout the client connection, request object, and location cache logic (both sync and async) to propagate and use the excluded_locations parameter.
- Updates to tests and documentation to include the new excluded_locations parameter in configuration and API docstrings.
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
sdk/cosmos/azure-cosmos/samples/excluded_locations.py | Adds new sample functions that demonstrate how to use excluded locations on both client and request levels. |
sdk/cosmos/azure-cosmos/test/test_globaldb.py | Adds a new test for verifying excluded locations behavior. |
sdk/cosmos/azure-cosmos/test/test_location_cache.py | Introduces parameterized tests for verifying regional endpoint filtering based on excluded locations. |
azure/cosmos/_request_object.py | Updates the RequestObject to set excluded locations from options. |
azure/cosmos/_cosmos_client_connection(.py and aio version) | Inserts calls to set excluded locations on request objects in various operations. |
azure/cosmos/_location_cache.py | Updates logic to filter read and write regional endpoints based on excluded locations and adds utility methods for this purpose. |
azure/cosmos/cosmos_client.py | Integrates the excluded_locations parameter into the connection policy used to initialize the client. |
azure/cosmos/documents.py | Updates documentation for ConnectionPolicy to include the new excluded_locations setting. |
azure/cosmos/_base.py | Adds the mapping for 'excluded_locations' in the common options used for building request headers. |
azure/cosmos/aio/_global_endpoint_manager_async.py and azure/cosmos/_global_endpoint_manager.py | Pass the connection_policy (including excluded_locations) to the LocationCache. |
azure/cosmos/container.py | Updates function docstrings to include the new excluded_locations parameter. |
Comments suppressed due to low confidence (1)
sdk/cosmos/azure-cosmos/samples/excluded_locations.py:98
- The word "manupilate" appears to be misspelled. Consider replacing it with "manipulate" for clarity.
if a user can manupilate the client level excluded locations for the specific request.
sdk/cosmos/azure-cosmos/azure/cosmos/_cosmos_client_connection.py
Outdated
Show resolved
Hide resolved
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.
Looking good overall, thanks Allen! Just had some questions.
Also, like Abhijeet mentioned, let's make sure to run some manual tests on this logic beforehand to make sure we don't miss anything.
sdk/cosmos/azure-cosmos/azure/cosmos/_cosmos_client_connection.py
Outdated
Show resolved
Hide resolved
sdk/cosmos/azure-cosmos/azure/cosmos/aio/_cosmos_client_connection_async.py
Outdated
Show resolved
Hide resolved
sdk/cosmos/azure-cosmos/azure/cosmos/aio/_global_endpoint_manager_async.py
Outdated
Show resolved
Hide resolved
In the future, let's try not to squash commits. It makes it much harder to track down original prs and when changes were made. |
This change will add excluded locations on
client
andrequest
levels.Design doc: https://microsoft-my.sharepoint.com/:w:/p/allekim/EWf4tc65_f9GiOv9aD2XkLMBD9h2ZAAXCcFTKghjutvqcg?e=AlD8w1
On Client level:
excluded_locations
parameter. This set will filter any existing preferred locations. If excluded locations filtered all preferred locations, Cosmos DB will use the default endpoints.On Request level:
excluded_locations
parameters along with any other parameters for Container level APIs. Thisexcluded_location
parameter will override the existing exlcuded locations on client level. This means also means that if a user can manupilate the client level excluded locations for the specific request. Moreover, if a user wants to skip all client level excluded locations, the user can simply pass an empty list[]
of excluded locations to skip all excluded location filters.Client level API works with
excluded_location
:All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines