Skip to content

Commit e12daee

Browse files
committed
chore: rename to WithRetry from RetryOperation
1 parent 30e2968 commit e12daee

9 files changed

Lines changed: 115 additions & 119 deletions

File tree

examples/src/main/java/software/amazon/lambda/durable/examples/callback/RetryWaitForCallbackExample.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
import java.time.Duration;
66
import software.amazon.lambda.durable.DurableContext;
77
import software.amazon.lambda.durable.DurableHandler;
8-
import software.amazon.lambda.durable.config.RetryOperationConfig;
8+
import software.amazon.lambda.durable.config.WithRetryConfig;
99
import software.amazon.lambda.durable.examples.types.ApprovalRequest;
1010
import software.amazon.lambda.durable.retry.RetryDecision;
11-
import software.amazon.lambda.durable.util.RetryOperationHelper;
11+
import software.amazon.lambda.durable.util.WithRetryHelper;
1212

1313
/**
14-
* Example demonstrating {@link RetryOperationHelper} with {@code context.waitForCallback}.
14+
* Example demonstrating {@link WithRetryHelper} with {@code context.waitForCallback}.
1515
*
1616
* <p>Submits an approval request to an external system via a callback. If the callback fails (e.g., the external system
1717
* rejects the request), the helper retries the entire waitForCallback cycle — creating a fresh callback with a new ID
@@ -33,12 +33,12 @@ public String handleRequest(ApprovalRequest input, DurableContext context) {
3333
stepCtx -> "Approval for: " + input.description() + " ($" + input.amount() + ")");
3434

3535
// Step 2: waitForCallback with retry — if the external system fails, try again with a fresh callback
36-
var approvalResult = RetryOperationHelper.retryOperation(
36+
var approvalResult = WithRetryHelper.retryOperation(
3737
context,
3838
(ctx, attempt) -> ctx.waitForCallback(
3939
"approval-" + attempt, String.class, (callbackId, stepCtx) -> stepCtx.getLogger()
4040
.info("Attempt {}: sending callback {} to approval system", attempt, callbackId)),
41-
RetryOperationConfig.builder()
41+
WithRetryConfig.builder()
4242
.retryStrategy((error, attempt) -> attempt < MAX_ATTEMPTS
4343
? RetryDecision.retry(Duration.ofSeconds(2))
4444
: RetryDecision.fail())

examples/src/main/java/software/amazon/lambda/durable/examples/invoke/RetryInvokeExample.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
import java.time.Duration;
66
import software.amazon.lambda.durable.DurableContext;
77
import software.amazon.lambda.durable.DurableHandler;
8-
import software.amazon.lambda.durable.config.RetryOperationConfig;
8+
import software.amazon.lambda.durable.config.WithRetryConfig;
99
import software.amazon.lambda.durable.examples.types.GreetingRequest;
1010
import software.amazon.lambda.durable.retry.RetryDecision;
11-
import software.amazon.lambda.durable.util.RetryOperationHelper;
11+
import software.amazon.lambda.durable.util.WithRetryHelper;
1212

1313
/**
14-
* Example demonstrating {@link RetryOperationHelper} with {@code context.invoke}.
14+
* Example demonstrating {@link WithRetryHelper} with {@code context.invoke}.
1515
*
1616
* <p>Retries a chained Lambda invocation up to 3 times with a fixed 2-second backoff between attempts. Each attempt
1717
* uses a unique operation name ({@code "call-greeting-1"}, {@code "call-greeting-2"}, etc.) so the execution history
@@ -25,14 +25,14 @@ public class RetryInvokeExample extends DurableHandler<GreetingRequest, String>
2525

2626
@Override
2727
public String handleRequest(GreetingRequest input, DurableContext context) {
28-
return RetryOperationHelper.retryOperation(
28+
return WithRetryHelper.retryOperation(
2929
context,
3030
(ctx, attempt) -> ctx.invoke(
3131
"call-greeting-" + attempt,
3232
"simple-step-example" + input.getName() + ":$LATEST",
3333
input,
3434
String.class),
35-
RetryOperationConfig.builder()
35+
WithRetryConfig.builder()
3636
.retryStrategy((error, attempt) -> attempt < MAX_ATTEMPTS
3737
? RetryDecision.retry(Duration.ofSeconds(2))
3838
: RetryDecision.fail())

sdk-integration-tests/src/test/java/software/amazon/lambda/durable/RetryInvokeIntegrationTest.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@
77
import java.time.Duration;
88
import org.junit.jupiter.api.Test;
99
import software.amazon.awssdk.services.lambda.model.ErrorObject;
10-
import software.amazon.lambda.durable.config.RetryOperationConfig;
10+
import software.amazon.lambda.durable.config.WithRetryConfig;
1111
import software.amazon.lambda.durable.exception.InvokeFailedException;
1212
import software.amazon.lambda.durable.model.ExecutionStatus;
1313
import software.amazon.lambda.durable.retry.RetryDecision;
1414
import software.amazon.lambda.durable.retry.RetryStrategies;
1515
import software.amazon.lambda.durable.testing.LocalDurableTestRunner;
16-
import software.amazon.lambda.durable.util.RetryOperationHelper;
16+
import software.amazon.lambda.durable.util.WithRetryHelper;
1717

1818
class RetryInvokeIntegrationTest {
1919

2020
@Test
2121
void invokeSucceedsOnFirstAttempt() {
2222
var runner = LocalDurableTestRunner.create(
2323
String.class,
24-
(input, context) -> RetryOperationHelper.retryOperation(
24+
(input, context) -> WithRetryHelper.retryOperation(
2525
context,
2626
(ctx, attempt) -> ctx.invoke("invoke-" + attempt, "target-fn", "{}", String.class),
27-
RetryOperationConfig.builder()
27+
WithRetryConfig.builder()
2828
.retryStrategy(RetryStrategies.fixedDelay(3, Duration.ofSeconds(2)))
2929
.build()));
3030

@@ -42,10 +42,10 @@ void invokeSucceedsOnFirstAttempt() {
4242
void invokeRetriesAfterFailure() {
4343
var runner = LocalDurableTestRunner.create(
4444
String.class,
45-
(input, context) -> RetryOperationHelper.retryOperation(
45+
(input, context) -> WithRetryHelper.retryOperation(
4646
context,
4747
(ctx, attempt) -> ctx.invoke("invoke-" + attempt, "target-fn", "{}", String.class),
48-
RetryOperationConfig.builder()
48+
WithRetryConfig.builder()
4949
.retryStrategy(RetryStrategies.fixedDelay(3, Duration.ofSeconds(2)))
5050
.build()));
5151

@@ -80,10 +80,10 @@ void invokeRetriesAfterFailure() {
8080
void invokeFailsAfterAllRetriesExhausted() {
8181
var runner = LocalDurableTestRunner.create(
8282
String.class,
83-
(input, context) -> RetryOperationHelper.retryOperation(
83+
(input, context) -> WithRetryHelper.retryOperation(
8484
context,
8585
(ctx, attempt) -> ctx.invoke("invoke-" + attempt, "target-fn", "{}", String.class),
86-
RetryOperationConfig.builder()
86+
WithRetryConfig.builder()
8787
.retryStrategy((error, attempt) ->
8888
attempt < 2 ? RetryDecision.retry(Duration.ofSeconds(1)) : RetryDecision.fail())
8989
.build()));
@@ -114,10 +114,10 @@ void invokeFailsAfterAllRetriesExhausted() {
114114
void invokeRetryWithCustomBackoffDelay() {
115115
var runner = LocalDurableTestRunner.create(
116116
String.class,
117-
(input, context) -> RetryOperationHelper.retryOperation(
117+
(input, context) -> WithRetryHelper.retryOperation(
118118
context,
119119
(ctx, attempt) -> ctx.invoke("invoke-" + attempt, "target-fn", "{}", String.class),
120-
RetryOperationConfig.builder()
120+
WithRetryConfig.builder()
121121
.retryStrategy((error, attempt) -> attempt < 3
122122
? RetryDecision.retry(Duration.ofSeconds(attempt * 5L))
123123
: RetryDecision.fail())
@@ -148,10 +148,10 @@ void invokeRetryWithStepsBeforeAndAfter() {
148148
var runner = LocalDurableTestRunner.create(String.class, (input, context) -> {
149149
var prefix = context.step("prepare", String.class, stepCtx -> "prepared");
150150

151-
var invokeResult = RetryOperationHelper.retryOperation(
151+
var invokeResult = WithRetryHelper.retryOperation(
152152
context,
153153
(ctx, attempt) -> ctx.invoke("invoke-" + attempt, "target-fn", "{}", String.class),
154-
RetryOperationConfig.builder()
154+
WithRetryConfig.builder()
155155
.retryStrategy(RetryStrategies.fixedDelay(3, Duration.ofSeconds(1)))
156156
.build());
157157

@@ -174,10 +174,10 @@ void invokeRetryWithStepsBeforeAndAfter() {
174174
void invokeRetryPreservesOriginalExceptionType() {
175175
var runner = LocalDurableTestRunner.create(String.class, (input, context) -> {
176176
try {
177-
return RetryOperationHelper.retryOperation(
177+
return WithRetryHelper.retryOperation(
178178
context,
179179
(ctx, attempt) -> ctx.invoke("invoke-" + attempt, "target-fn", "{}", String.class),
180-
RetryOperationConfig.builder()
180+
WithRetryConfig.builder()
181181
.retryStrategy(RetryStrategies.Presets.NO_RETRY)
182182
.build());
183183
} catch (InvokeFailedException e) {

sdk-integration-tests/src/test/java/software/amazon/lambda/durable/RetryWaitForCallbackIntegrationTest.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@
77
import java.time.Duration;
88
import org.junit.jupiter.api.Test;
99
import software.amazon.awssdk.services.lambda.model.ErrorObject;
10-
import software.amazon.lambda.durable.config.RetryOperationConfig;
10+
import software.amazon.lambda.durable.config.WithRetryConfig;
1111
import software.amazon.lambda.durable.model.ExecutionStatus;
1212
import software.amazon.lambda.durable.retry.RetryDecision;
1313
import software.amazon.lambda.durable.retry.RetryStrategies;
1414
import software.amazon.lambda.durable.testing.LocalDurableTestRunner;
15-
import software.amazon.lambda.durable.util.RetryOperationHelper;
15+
import software.amazon.lambda.durable.util.WithRetryHelper;
1616

1717
class RetryWaitForCallbackIntegrationTest {
1818

1919
@Test
2020
void waitForCallbackSucceedsOnFirstAttempt() {
2121
var runner = LocalDurableTestRunner.create(
2222
String.class,
23-
(input, context) -> RetryOperationHelper.retryOperation(
23+
(input, context) -> WithRetryHelper.retryOperation(
2424
context,
2525
(ctx, attempt) -> ctx.waitForCallback(
2626
"approval-" + attempt, String.class, (callbackId, stepCtx) -> stepCtx.getLogger()
2727
.info("Submitting callback {}", callbackId)),
28-
RetryOperationConfig.builder()
28+
WithRetryConfig.builder()
2929
.retryStrategy(RetryStrategies.fixedDelay(3, Duration.ofSeconds(2)))
3030
.build()));
3131

@@ -47,12 +47,12 @@ void waitForCallbackSucceedsOnFirstAttempt() {
4747
void waitForCallbackRetriesAfterFailure() {
4848
var runner = LocalDurableTestRunner.create(
4949
String.class,
50-
(input, context) -> RetryOperationHelper.retryOperation(
50+
(input, context) -> WithRetryHelper.retryOperation(
5151
context,
5252
(ctx, attempt) -> ctx.waitForCallback(
5353
"approval-" + attempt, String.class, (callbackId, stepCtx) -> stepCtx.getLogger()
5454
.info("Attempt {} callback {}", attempt, callbackId)),
55-
RetryOperationConfig.builder()
55+
WithRetryConfig.builder()
5656
.retryStrategy(RetryStrategies.fixedDelay(3, Duration.ofSeconds(2)))
5757
.build()));
5858

@@ -94,11 +94,11 @@ void waitForCallbackRetriesAfterFailure() {
9494
void waitForCallbackFailsAfterAllRetriesExhausted() {
9595
var runner = LocalDurableTestRunner.create(
9696
String.class,
97-
(input, context) -> RetryOperationHelper.retryOperation(
97+
(input, context) -> WithRetryHelper.retryOperation(
9898
context,
9999
(ctx, attempt) ->
100100
ctx.waitForCallback("approval-" + attempt, String.class, (callbackId, stepCtx) -> {}),
101-
RetryOperationConfig.builder()
101+
WithRetryConfig.builder()
102102
.retryStrategy((error, attempt) ->
103103
attempt < 2 ? RetryDecision.retry(Duration.ofSeconds(1)) : RetryDecision.fail())
104104
.build()));
@@ -132,11 +132,11 @@ void waitForCallbackRetryWithStepsBeforeAndAfter() {
132132
var runner = LocalDurableTestRunner.create(String.class, (input, context) -> {
133133
var prefix = context.step("prepare", String.class, stepCtx -> "prepared");
134134

135-
var callbackResult = RetryOperationHelper.retryOperation(
135+
var callbackResult = WithRetryHelper.retryOperation(
136136
context,
137137
(ctx, attempt) ->
138138
ctx.waitForCallback("approval-" + attempt, String.class, (callbackId, stepCtx) -> {}),
139-
RetryOperationConfig.builder()
139+
WithRetryConfig.builder()
140140
.retryStrategy(RetryStrategies.fixedDelay(3, Duration.ofSeconds(1)))
141141
.build());
142142

@@ -161,11 +161,11 @@ void waitForCallbackRetryWithStepsBeforeAndAfter() {
161161
void waitForCallbackRetryMultipleFailuresThenSuccess() {
162162
var runner = LocalDurableTestRunner.create(
163163
String.class,
164-
(input, context) -> RetryOperationHelper.retryOperation(
164+
(input, context) -> WithRetryHelper.retryOperation(
165165
context,
166166
(ctx, attempt) ->
167167
ctx.waitForCallback("cb-" + attempt, String.class, (callbackId, stepCtx) -> {}),
168-
RetryOperationConfig.builder()
168+
WithRetryConfig.builder()
169169
.retryStrategy(RetryStrategies.fixedDelay(4, Duration.ofSeconds(1)))
170170
.build()));
171171

@@ -207,15 +207,15 @@ void waitForCallbackRetryWithSubmitterLogic() {
207207
// Verify the submitter runs on each retry attempt
208208
var runner = LocalDurableTestRunner.create(
209209
String.class,
210-
(input, context) -> RetryOperationHelper.retryOperation(
210+
(input, context) -> WithRetryHelper.retryOperation(
211211
context,
212212
(ctx, attempt) ->
213213
ctx.waitForCallback("approval-" + attempt, String.class, (callbackId, stepCtx) -> {
214214
// Submitter runs each attempt — in a real scenario this would
215215
// send the callbackId to an external system
216216
stepCtx.getLogger().info("Attempt {} submitting {}", attempt, callbackId);
217217
}),
218-
RetryOperationConfig.builder()
218+
WithRetryConfig.builder()
219219
.retryStrategy(RetryStrategies.fixedDelay(3, Duration.ofSeconds(2)))
220220
.build()));
221221

sdk/src/main/java/software/amazon/lambda/durable/config/RetryOperationConfig.java renamed to sdk/src/main/java/software/amazon/lambda/durable/config/WithRetryConfig.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
import software.amazon.lambda.durable.retry.RetryStrategy;
66

77
/**
8-
* Configuration for {@link software.amazon.lambda.durable.util.RetryOperationHelper#retryOperation}.
8+
* Configuration for {@link software.amazon.lambda.durable.util.WithRetryHelper#retryOperation}.
99
*
1010
* <p>Uses the same {@link RetryStrategy} shape that developers already know from {@link StepConfig}, so there are zero
1111
* new retry concepts to learn.
1212
*/
13-
public class RetryOperationConfig {
13+
public class WithRetryConfig {
1414
private final RetryStrategy retryStrategy;
1515
private final boolean wrapInChildContext;
1616

17-
private RetryOperationConfig(Builder builder) {
17+
private WithRetryConfig(Builder builder) {
1818
this.retryStrategy = builder.retryStrategy;
1919
this.wrapInChildContext = builder.wrapInChildContext;
2020
}
@@ -40,15 +40,15 @@ public boolean wrapInChildContext() {
4040
}
4141

4242
/**
43-
* Creates a new builder for {@code RetryOperationConfig}.
43+
* Creates a new builder for {@code WithRetryConfig}.
4444
*
4545
* @return a new builder instance
4646
*/
4747
public static Builder builder() {
4848
return new Builder();
4949
}
5050

51-
/** Builder for creating {@link RetryOperationConfig} instances. */
51+
/** Builder for creating {@link WithRetryConfig} instances. */
5252
public static class Builder {
5353
private RetryStrategy retryStrategy;
5454
private boolean wrapInChildContext = true;
@@ -88,16 +88,16 @@ public Builder wrapInChildContext(boolean wrapInChildContext) {
8888
}
8989

9090
/**
91-
* Builds the {@link RetryOperationConfig} instance.
91+
* Builds the {@link WithRetryConfig} instance.
9292
*
9393
* @return a new config with the configured options
9494
* @throws IllegalArgumentException if retryStrategy is not set
9595
*/
96-
public RetryOperationConfig build() {
96+
public WithRetryConfig build() {
9797
if (retryStrategy == null) {
9898
throw new IllegalArgumentException("retryStrategy is required");
9999
}
100-
return new RetryOperationConfig(this);
100+
return new WithRetryConfig(this);
101101
}
102102
}
103103
}

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
@@ -5,7 +5,7 @@
55
import software.amazon.lambda.durable.DurableContext;
66

77
/**
8-
* A durable operation that can be retried end-to-end by {@link RetryOperationHelper}.
8+
* A durable operation that can be retried end-to-end by {@link WithRetryHelper}.
99
*
1010
* <p>Receives the durable context and the 1-based attempt number so callers can generate unique operation names per
1111
* attempt (e.g., {@code "approval-" + attempt}).

0 commit comments

Comments
 (0)