Skip to content

Commit 30e2968

Browse files
committed
chore: rename to withRetry from RetryableOperation
1 parent 7fd1628 commit 30e2968

4 files changed

Lines changed: 10 additions & 11 deletions

File tree

sdk/src/main/java/software/amazon/lambda/durable/util/RetryOperationHelper.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private RetryOperationHelper() {
7979
*/
8080
@SuppressWarnings("unchecked")
8181
public static <T> T retryOperation(
82-
DurableContext context, String name, RetryableOperation<T> operation, RetryOperationConfig config) {
82+
DurableContext context, String name, WithRetry<T> operation, RetryOperationConfig config) {
8383
Objects.requireNonNull(context, "context cannot be null");
8484
Objects.requireNonNull(name, "name cannot be null");
8585
Objects.requireNonNull(operation, "operation cannot be null");
@@ -102,8 +102,7 @@ public static <T> T retryOperation(
102102
* @param config retry configuration including the retry strategy
103103
* @return the operation result
104104
*/
105-
public static <T> T retryOperation(
106-
DurableContext context, RetryableOperation<T> operation, RetryOperationConfig config) {
105+
public static <T> T retryOperation(DurableContext context, WithRetry<T> operation, RetryOperationConfig config) {
107106
Objects.requireNonNull(context, "context cannot be null");
108107
Objects.requireNonNull(operation, "operation cannot be null");
109108
Objects.requireNonNull(config, "config cannot be null");
@@ -119,7 +118,7 @@ public static <T> T retryOperation(
119118
* are internal SDK control flow signals that must propagate immediately.
120119
*/
121120
private static <T> T executeRetryLoop(
122-
DurableContext context, String name, RetryableOperation<T> operation, RetryOperationConfig config) {
121+
DurableContext context, String name, WithRetry<T> operation, RetryOperationConfig config) {
123122
var attempt = 1;
124123
while (true) {
125124
try {

sdk/src/main/java/software/amazon/lambda/durable/util/RetryableOperation.java renamed to sdk/src/main/java/software/amazon/lambda/durable/util/WithRetry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* @param <T> the result type
1414
*/
1515
@FunctionalInterface
16-
public interface RetryableOperation<T> {
16+
public interface WithRetry<T> {
1717

1818
/**
1919
* Executes the durable operation.

sdk/src/test/java/software/amazon/lambda/durable/util/RetryOperationHelperTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ void nullOperation_shouldThrow() {
272272

273273
assertThrows(
274274
NullPointerException.class,
275-
() -> RetryOperationHelper.retryOperation(context, (RetryableOperation<String>) null, config));
275+
() -> RetryOperationHelper.retryOperation(context, (WithRetry<String>) null, config));
276276
}
277277

278278
@Test

sdk/src/test/java/software/amazon/lambda/durable/util/RetryableOperationTest.java renamed to sdk/src/test/java/software/amazon/lambda/durable/util/WithRetryTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
import org.junit.jupiter.api.Test;
99
import software.amazon.lambda.durable.DurableContext;
1010

11-
class RetryableOperationTest {
11+
class WithRetryTest {
1212

1313
@Test
1414
void canBeImplementedAsLambda() {
15-
RetryableOperation<String> operation = (ctx, attempt) -> "result-" + attempt;
15+
WithRetry<String> operation = (ctx, attempt) -> "result-" + attempt;
1616
var context = mock(DurableContext.class);
1717

1818
assertEquals("result-1", operation.execute(context, 1));
@@ -22,7 +22,7 @@ void canBeImplementedAsLambda() {
2222
@Test
2323
void receivesContextAndAttempt() {
2424
var context = mock(DurableContext.class);
25-
RetryableOperation<String> operation = (ctx, attempt) -> {
25+
WithRetry<String> operation = (ctx, attempt) -> {
2626
assertSame(context, ctx);
2727
return "attempt-" + attempt;
2828
};
@@ -33,7 +33,7 @@ void receivesContextAndAttempt() {
3333

3434
@Test
3535
void canThrowExceptions() {
36-
RetryableOperation<String> operation = (ctx, attempt) -> {
36+
WithRetry<String> operation = (ctx, attempt) -> {
3737
throw new RuntimeException("failed on attempt " + attempt);
3838
};
3939
var context = mock(DurableContext.class);
@@ -44,7 +44,7 @@ void canThrowExceptions() {
4444

4545
@Test
4646
void canReturnNull() {
47-
RetryableOperation<String> operation = (ctx, attempt) -> null;
47+
WithRetry<String> operation = (ctx, attempt) -> null;
4848
var context = mock(DurableContext.class);
4949

5050
assertNull(operation.execute(context, 1));

0 commit comments

Comments
 (0)