Add custom shouldComplete completion decisions#524
Merged
Conversation
ParidelPooya
approved these changes
Jul 9, 2026
wangyb-A
approved these changes
Jul 9, 2026
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.
Summary
CompletionConfig.shouldCompleteas aCompletionDecision.allCompleted,allSuccessful,firstSuccessful,minSuccessful, tolerated failure configs) by building them on top of the same decision function.CUSTOM_COMPLETION_SUCCEEDEDandCUSTOM_COMPLETION_FAILED.CustomShouldCompleteMapExamplewith local tests plus README and SAM template wiring.Difference from the JS proposal
This is based on the same feature request as aws-durable-execution-sdk-js#701, but the Java API is intentionally a bit stricter and more explicit:
shouldComplete: (status) => boolean; Java usesFunction<CompletionStatus, CompletionDecision>so the custom condition decides both whether to complete and whichConcurrencyCompletionStatusto report.shouldCompletetakes precedence and threshold fields are ignored. Java makesshouldCompletemutually exclusive withminSuccessful,toleratedFailureCount, andtoleratedFailurePercentageso ambiguous configs fail fast.CUSTOM_COMPLETIONreason and derives success/failure from item outcomes. Java does not add genericCUSTOM_COMPLETION; custom completion must chooseCUSTOM_COMPLETION_SUCCEEDEDorCUSTOM_COMPLETION_FAILED, and success is carried by the enum viacompletionStatus.isSucceeded().succeededflag fromCompletionDecision; completed decisions must always provide aConcurrencyCompletionStatus, and the status itself owns success semantics.shouldCompleteresult when custom completion is configured. It does not automatically convert all-items-completed intoALL_COMPLETED; callers that want an all-completed fallback can return that decision from their callback usingstatus.allCompleted().allItemsRegisteredonCompletionStatus, in addition to the count fields, so callbacks can distinguish “all currently registered items are done” from “the caller has finished registering items”.canComplete) instead of wrapping the user callback insideCompletionConfig.Testing
mvn spotless:applymvn -pl examples -am -Dtest=CustomShouldCompleteMapExampleTest -Dsurefire.failIfNoSpecifiedTests=false testmvn -pl sdk -Dtest=CompletionConfigTest,ConcurrencyCompletionStatusTest,MapResultTest,ParallelResultTest,ParallelConfigTest,ConcurrencyOperationTest,ParallelOperationTest testmvn -pl sdk,sdk-integration-tests -Dtest=MapIntegrationTest,ParallelIntegrationTest -Dsurefire.failIfNoSpecifiedTests=false testgit diff --checkgit diff --cached --check