-
Notifications
You must be signed in to change notification settings - Fork 223
Add Failure Policy for Jobs SDK #1448
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
Merged
dapr-bot
merged 30 commits into
dapr:master
from
siri-varma:users/svegiraju/add-failure-policy
Aug 5, 2025
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
bb56b8d
Update CONTRIBUTING.md
siri-varma f09bf44
Merge branch 'dapr:master' into master
siri-varma 64d2fe3
Merge branch 'dapr:master' into master
siri-varma d50775c
Merge branch 'dapr:master' into master
siri-varma 0b3e757
Merge branch 'dapr:master' into master
siri-varma c30f537
Merge branch 'dapr:master' into master
siri-varma 29eac2e
Merge branch 'master' of https://github.com/siri-varma/java-sdk
siri-varma b713413
Add failrue policy
siri-varma 8c05789
Add tests
siri-varma 3e5a384
Add Tests
siri-varma 8828335
Merge branch 'master' into users/svegiraju/add-failure-policy
siri-varma a0b8a48
Merge branch 'master' into users/svegiraju/add-failure-policy
artur-ciocanu 6cd3bca
Merge branch 'master' into users/svegiraju/add-failure-policy
siri-varma 3b9fc1c
Upgrading to 1.15.7 (#1458)
salaboy 6a07cb3
Rename classes
siri-varma 7e64c73
Merge branch 'master' into users/svegiraju/add-failure-policy
artur-ciocanu 9c0c66e
Merge branch 'master' into users/svegiraju/add-failure-policy
artur-ciocanu 1eb4ad0
Merge branch 'master' into users/svegiraju/add-failure-policy
siri-varma cbf5320
add rc
siri-varma cb0131e
add rc
siri-varma 6902b30
fix checkstyle
siri-varma dd6fe55
Fix things
siri-varma 66488ae
Test latest
siri-varma 6ad648c
fix checkstyle
siri-varma aafee46
Merge pull request #2 from siri-varma/users/svegiraju/test-latest
siri-varma d023c9f
Merge branch 'master' into users/svegiraju/add-failure-policy
artur-ciocanu 67c9d4a
Merge branch 'master' into users/svegiraju/add-failure-policy
siri-varma 5b11ef8
Address comments
siri-varma 8a0065d
Merge branch 'users/svegiraju/add-failure-policy' of https://github.c…
siri-varma 28017f8
Address comments
siri-varma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
95 changes: 95 additions & 0 deletions
95
sdk/src/main/java/io/dapr/client/domain/ConstantFailurePolicy.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* Copyright 2021 The Dapr Authors | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package io.dapr.client.domain; | ||
|
||
import java.time.Duration; | ||
|
||
/** | ||
* A failure policy that applies a constant retry interval for job retries. | ||
* This implementation of {@link FailurePolicy} retries a job a fixed number of times | ||
* with a constant delay between each retry attempt. | ||
*/ | ||
public class ConstantFailurePolicy implements FailurePolicy { | ||
|
||
private Integer maxRetries; | ||
private Duration durationBetweenRetries; | ||
|
||
/** | ||
* Constructs a {@code JobConstantFailurePolicy} with the specified maximum number of retries. | ||
* | ||
* @param maxRetries the maximum number of retries | ||
*/ | ||
public ConstantFailurePolicy(Integer maxRetries) { | ||
this.maxRetries = maxRetries; | ||
} | ||
|
||
/** | ||
* Constructs a {@code JobConstantFailurePolicy} with the specified duration between retries. | ||
* | ||
* @param durationBetweenRetries the duration to wait between retries | ||
*/ | ||
public ConstantFailurePolicy(Duration durationBetweenRetries) { | ||
this.durationBetweenRetries = durationBetweenRetries; | ||
} | ||
|
||
/** | ||
* Sets the duration to wait between retry attempts. | ||
* | ||
* @param durationBetweenRetries the duration between retries | ||
* @return a {@code JobFailurePolicyConstant}. | ||
*/ | ||
public ConstantFailurePolicy setDurationBetweenRetries(Duration durationBetweenRetries) { | ||
this.durationBetweenRetries = durationBetweenRetries; | ||
return this; | ||
} | ||
|
||
/** | ||
* Sets the maximum number of retries allowed. | ||
* | ||
* @param maxRetries the number of retries | ||
* @return a {@code JobFailurePolicyConstant}. | ||
*/ | ||
public ConstantFailurePolicy setMaxRetries(int maxRetries) { | ||
this.maxRetries = maxRetries; | ||
return this; | ||
} | ||
|
||
/** | ||
* Returns the configured duration between retry attempts. | ||
* | ||
* @return the duration between retries | ||
*/ | ||
public Duration getDurationBetweenRetries() { | ||
return this.durationBetweenRetries; | ||
} | ||
|
||
/** | ||
* Returns the configured maximum number of retries. | ||
* | ||
* @return the maximum number of retries | ||
*/ | ||
public Integer getMaxRetries() { | ||
return this.maxRetries; | ||
} | ||
|
||
/** | ||
* Returns the type of failure policy. | ||
* | ||
* @return {@link FailurePolicyType#CONSTANT} | ||
*/ | ||
@Override | ||
public FailurePolicyType getFailurePolicyType() { | ||
return FailurePolicyType.CONSTANT; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
sdk/src/main/java/io/dapr/client/domain/DropFailurePolicy.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2021 The Dapr Authors | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package io.dapr.client.domain; | ||
|
||
/** | ||
* A failure policy that drops the job upon failure without retrying. | ||
* This implementation of {@link FailurePolicy} immediately discards failed jobs | ||
* instead of retrying them. | ||
*/ | ||
public class DropFailurePolicy implements FailurePolicy { | ||
|
||
/** | ||
* Returns the type of failure policy. | ||
* | ||
* @return {@link FailurePolicyType#DROP} | ||
*/ | ||
@Override | ||
public FailurePolicyType getFailurePolicyType() { | ||
return FailurePolicyType.DROP; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
sdk/src/main/java/io/dapr/client/domain/FailurePolicy.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright 2025 The Dapr Authors | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package io.dapr.client.domain; | ||
|
||
/** | ||
* Set a failure policy for the job. | ||
*/ | ||
public interface FailurePolicy { | ||
FailurePolicyType getFailurePolicyType(); | ||
} |
20 changes: 20 additions & 0 deletions
20
sdk/src/main/java/io/dapr/client/domain/FailurePolicyType.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright 2025 The Dapr Authors | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package io.dapr.client.domain; | ||
|
||
public enum FailurePolicyType { | ||
DROP, | ||
|
||
CONSTANT | ||
} |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.