Skip to content
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

Conditional Patch SDK #19307

Merged

Conversation

deparash
Copy link
Contributor

@deparash deparash commented Feb 18, 2021

This PR introduces conditional Patch to Java SDK.

Patch requests have the option that it can be triggered only when the condition attached is true.
The new condition(filter predicate) is attached along with request options and is processed for the respective document.

@ghost ghost added the Cosmos label Feb 18, 2021
@check-enforcer
Copy link

This pull request is protected by Check Enforcer.

What is Check Enforcer?

Check Enforcer helps ensure all pull requests are covered by at least one check-run (typically an Azure Pipeline). When all check-runs associated with this pull request pass then Check Enforcer itself will pass.

Why am I getting this message?

You are getting this message because Check Enforcer did not detect any check-runs being associated with this pull request within five minutes. This may indicate that your pull request is not covered by any pipelines and so Check Enforcer is correctly blocking the pull request being merged.

What should I do now?

If the check-enforcer check-run is not passing and all other check-runs associated with this PR are passing (excluding license-cla) then you could try telling Check Enforcer to evaluate your pull request again. You can do this by adding a comment to this pull request as follows:
/check-enforcer evaluate
Typically evaulation only takes a few seconds. If you know that your pull request is not covered by a pipeline and this is expected you can override Check Enforcer using the following command:
/check-enforcer override
Note that using the override command triggers alerts so that follow-up investigations can occur (PRs still need to be approved as normal).

What if I am onboarding a new service?

Often, new services do not have validation pipelines associated with them, in order to bootstrap pipelines for a new service, you can issue the following command as a pull request comment:
/azp run prepare-pipelines
This will run a pipeline that analyzes the source tree and creates the pipelines necessary to build and validate your pull request. Once the pipeline has been created you can trigger the pipeline using the following comment:
/azp run java - [service] - ci

@deparash deparash changed the title Draft 1 for Conditional Patch SDK Conditional Patch SDK Feb 24, 2021
Copy link
Contributor

@moderakh moderakh left a comment

Choose a reason for hiding this comment

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

LGTM. Please make sure you address Fabian's comments as well.

This is not introduced in this PR. we can close on this one outside of the scope of this PR.
But so we remember to discuss it, the current Patch api asks for 5 arg which is debatable if it is easy to use.

container.patchItem(
        String itemId,
        PartitionKey partitionKey,
        CosmosPatchOperations cosmosPatchOperations,
        CosmosPatchItemRequestOptions options,
        Class<T> itemType)

@FabianMeiswinkel @kushagraThapar @milismsft thought on using 5 args here?

@@ -1003,19 +1014,19 @@ public String getId() {
String itemId,
PartitionKey partitionKey,
CosmosPatchOperations cosmosPatchOperations,
CosmosItemRequestOptions options,
CosmosPatchItemRequestOptions options,
Copy link
Contributor

Choose a reason for hiding this comment

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

I know that this is not introduced in this PR. So we don't have to find a solution to it in this PR.
But we need to pay attention what we should do.

We have a method here with 5 args which IMO in Java is not as great. We have tried to limit the number of args in the public surface area for better usability.

@FabianMeiswinkel @kushagraThapar @milismsft what's your thought on a method with 5 args here? thought?

Copy link
Member

Choose a reason for hiding this comment

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

As discussed offline - I don't have a proposal for a better way (that is consistent with the approach for other point operations). itemId, pk and item Type are required. The only alternative I see is to push id, pk and itemType into CosmosPatchOperations as required parameters for the static create factory method.
But IMO this is more confusing because it could create the impression that path operations can spread across documents/items - I prefer the current mode which allows factoring the patchOperations and reuse it for different documents.

Copy link
Member

@FabianMeiswinkel FabianMeiswinkel left a comment

Choose a reason for hiding this comment

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

LGTM now - thanks!

@FabianMeiswinkel FabianMeiswinkel merged commit 10c391f into Azure:master Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants