Record Class CompletionConfig
java.lang.Object
java.lang.Record
software.amazon.lambda.durable.config.CompletionConfig
public record CompletionConfig(Integer minSuccessful, Integer toleratedFailureCount, Double toleratedFailurePercentage, Function<CompletionConfig.CompletionStatus,CompletionConfig.CompletionDecision> shouldComplete)
extends Record
Controls when a concurrent operation (map or parallel) completes.
Provides factory methods for common completion strategies and fine-grained control via minSuccessful,
toleratedFailureCount, toleratedFailurePercentage, and shouldComplete.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordThe completion decision returned bycompletionDecisionFunction().static final recordLive completion progress for a map or parallel operation. -
Constructor Summary
ConstructorsConstructorDescriptionCompletionConfig(Integer minSuccessful, Integer toleratedFailureCount, Double toleratedFailurePercentage) CompletionConfig(Integer minSuccessful, Integer toleratedFailureCount, Double toleratedFailurePercentage, Function<CompletionConfig.CompletionStatus, CompletionConfig.CompletionDecision> shouldComplete) Creates an instance of aCompletionConfigrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic CompletionConfigAll items run regardless of failures.static CompletionConfigAll items must succeed.Returns the completion decision function.final booleanIndicates whether some other object is "equal to" this one.static CompletionConfigComplete as soon as the first item succeeds.booleanfinal inthashCode()Returns a hash code value for this object.Returns the value of theminSuccessfulrecord component.static CompletionConfigminSuccessful(int count) Complete when the specified number of items have succeeded.Returns the value of theshouldCompleterecord component.static CompletionConfigshouldComplete(Function<CompletionConfig.CompletionStatus, CompletionConfig.CompletionDecision> shouldComplete) Complete when the function returns a completing decision.Returns the value of thetoleratedFailureCountrecord component.static CompletionConfigtoleratedFailureCount(int count) Complete when more than the specified number of failures have occurred.Returns the value of thetoleratedFailurePercentagerecord component.static CompletionConfigtoleratedFailurePercentage(double percentage) Complete when the failure percentage exceeds the specified threshold (0.0 to 1.0).final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
CompletionConfig
-
CompletionConfig
public CompletionConfig(Integer minSuccessful, Integer toleratedFailureCount, Double toleratedFailurePercentage, Function<CompletionConfig.CompletionStatus, CompletionConfig.CompletionDecision> shouldComplete) Creates an instance of aCompletionConfigrecord class.- Parameters:
minSuccessful- the value for theminSuccessfulrecord componenttoleratedFailureCount- the value for thetoleratedFailureCountrecord componenttoleratedFailurePercentage- the value for thetoleratedFailurePercentagerecord componentshouldComplete- the value for theshouldCompleterecord component
-
-
Method Details
-
allSuccessful
All items must succeed. Zero failures tolerated. -
allCompleted
All items run regardless of failures. Failures captured per-item. -
firstSuccessful
Complete as soon as the first item succeeds. -
minSuccessful
Complete when the specified number of items have succeeded. -
toleratedFailureCount
Complete when more than the specified number of failures have occurred. -
toleratedFailurePercentage
Complete when the failure percentage exceeds the specified threshold (0.0 to 1.0). -
shouldComplete
public static CompletionConfig shouldComplete(Function<CompletionConfig.CompletionStatus, CompletionConfig.CompletionDecision> shouldComplete) Complete when the function returns a completing decision.The decision controls whether the operation completes, the reported completion status, and whether that status represents success.
-
completionDecisionFunction
public Function<CompletionConfig.CompletionStatus,CompletionConfig.CompletionDecision> completionDecisionFunction()Returns the completion decision function. Legacy threshold fields are converted into this function so concurrent operations only need one completion mechanism. -
hasCustomShouldComplete
public boolean hasCustomShouldComplete()- Returns:
- true when a custom completion function is configured.
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
minSuccessful
Returns the value of theminSuccessfulrecord component.- Returns:
- the value of the
minSuccessfulrecord component
-
toleratedFailureCount
Returns the value of thetoleratedFailureCountrecord component.- Returns:
- the value of the
toleratedFailureCountrecord component
-
toleratedFailurePercentage
Returns the value of thetoleratedFailurePercentagerecord component.- Returns:
- the value of the
toleratedFailurePercentagerecord component
-
shouldComplete
public Function<CompletionConfig.CompletionStatus,CompletionConfig.CompletionDecision> shouldComplete()Returns the value of theshouldCompleterecord component.- Returns:
- the value of the
shouldCompleterecord component
-