Skip to content

[Cosmos] reformat availability_strategy use#45141

Merged
simorenoh merged 31 commits intomainfrom
additional-cosmos-review
Feb 19, 2026
Merged

[Cosmos] reformat availability_strategy use#45141
simorenoh merged 31 commits intomainfrom
additional-cosmos-review

Conversation

@simorenoh
Copy link
Member

@simorenoh simorenoh commented Feb 11, 2026

Missed the fact that there were additional questions on the cross-regional hedging functionality and that we had exposed an inner policy. Addressing both of these here.

Updates availability_strategy to be bool/dict as opposed to just dict for easier usage.

The way availability_strategy works has been updated to the following at the client level:

    :keyword Union[bool, dict[str, Any]] availability_strategy:
        Enables an availability strategy by using cross-region request hedging.
        Can be True (use default values: threshold_ms=500, threshold_steps_ms=100),
        False (disable hedging)
        or a dict with keys ``threshold_ms`` and ``threshold_steps_ms`` to configure custom values.
        Default value is False (hedging disabled).

The way availability_strategy works has been updated to the following at the request level:

        :keyword Union[bool, dict[str, Any]] availability_strategy: Enables an availability strategy by using cross-region request hedging.
            Can be True (use client config if present, otherwise use default values: threshold_ms=500, threshold_steps_ms=100),
            False (disable hedging even if client has it enabled),
            or a dict with keys ``threshold_ms`` and ``threshold_steps_ms`` to override the client's configured availability strategy.
            If not provided, uses the client's configured strategy.

@simorenoh simorenoh requested a review from a team as a code owner February 11, 2026 23:22
Copilot AI review requested due to automatic review settings February 11, 2026 23:22
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Addresses missing API-view/documentation details for Cosmos cross-region hedging and hides an internal user-agent policy implementation.

Changes:

  • Expanded availability_strategy docstrings to describe cross-region hedging configuration.
  • Moved CosmosUserAgentPolicy into a new internal module (_user_agent_policy.py) and updated sync/async imports accordingly.
  • Updated cross-region hedging README content (plus changelog date adjustment).

Reviewed changes

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

Show a summary per file
File Description
sdk/cosmos/azure-cosmos/fix_docstrings.py Adds a one-off script intended to rewrite docstrings in container modules.
sdk/cosmos/azure-cosmos/azure/cosmos/cosmos_client.py Updates CosmosClient constructor docstring for availability_strategy.
sdk/cosmos/azure-cosmos/azure/cosmos/container.py Updates multiple container method docstrings for availability_strategy.
sdk/cosmos/azure-cosmos/azure/cosmos/aio/_cosmos_client_connection_async.py Switches async connection to import the internal _user_agent_policy.
sdk/cosmos/azure-cosmos/azure/cosmos/aio/_container.py Updates multiple async container method docstrings for availability_strategy.
sdk/cosmos/azure-cosmos/azure/cosmos/_user_agent_policy.py Introduces internal CosmosUserAgentPolicy implementation.
sdk/cosmos/azure-cosmos/azure/cosmos/_cosmos_client_connection.py Switches sync connection to import the internal _user_agent_policy.
sdk/cosmos/azure-cosmos/README.md Updates cross-region hedging docs and adds a “Best Practices” section.
sdk/cosmos/azure-cosmos/CHANGELOG.md Adjusts the 4.15.0 entry date.

@github-actions
Copy link

github-actions bot commented Feb 11, 2026

API Change Check

APIView identified API level changes in this PR and created the following API reviews

azure-cosmos

@simorenoh simorenoh requested a review from annatisch February 12, 2026 21:12
@simorenoh
Copy link
Member Author

/azp run python - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@simorenoh
Copy link
Member Author

/azp run python - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@simorenoh
Copy link
Member Author

/azp run python - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@simorenoh
Copy link
Member Author

/azp run python - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@simorenoh simorenoh changed the title [Cosmos] address missing API view bits [Cosmos] reformat availability_strategy use Feb 19, 2026
@simorenoh simorenoh merged commit c879eed into main Feb 19, 2026
39 checks passed
@simorenoh simorenoh deleted the additional-cosmos-review branch February 19, 2026 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants