Skip to content

Commit 8eaa584

Browse files
authored
clean up null for subType (#197)
1 parent cb78812 commit 8eaa584

8 files changed

Lines changed: 21 additions & 12 deletions

File tree

sdk/src/main/java/software/amazon/lambda/durable/DurableContext.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public <T> DurableFuture<T> stepAsync(
135135

136136
// Create and start step operation with TypeToken
137137
var operation = new StepOperation<>(
138-
new OperationIdentifier(operationId, name, OperationType.STEP, null), func, typeToken, config, this);
138+
OperationIdentifier.of(operationId, name, OperationType.STEP), func, typeToken, config, this);
139139

140140
operation.execute(); // Start the step (returns immediately)
141141

@@ -205,7 +205,7 @@ public DurableFuture<Void> waitAsync(String name, Duration duration) {
205205

206206
// Create and start wait operation
207207
var operation =
208-
new WaitOperation(new OperationIdentifier(operationId, name, OperationType.WAIT, null), duration, this);
208+
new WaitOperation(OperationIdentifier.of(operationId, name, OperationType.WAIT), duration, this);
209209

210210
operation.execute(); // Checkpoint the wait
211211
return operation;
@@ -279,7 +279,7 @@ public <T, U> DurableFuture<T> invokeAsync(
279279

280280
// Create and start invoke operation
281281
var operation = new InvokeOperation<>(
282-
new OperationIdentifier(operationId, name, OperationType.CHAINED_INVOKE, null),
282+
OperationIdentifier.of(operationId, name, OperationType.CHAINED_INVOKE),
283283
functionName,
284284
payload,
285285
typeToken,
@@ -313,7 +313,7 @@ public <T> DurableCallbackFuture<T> createCallback(String name, TypeToken<T> typ
313313
var operationId = nextOperationId();
314314

315315
var operation = new CallbackOperation<>(
316-
new OperationIdentifier(operationId, name, OperationType.CALLBACK, null), typeToken, config, this);
316+
OperationIdentifier.of(operationId, name, OperationType.CALLBACK), typeToken, config, this);
317317
operation.execute();
318318

319319
return operation;
@@ -346,7 +346,7 @@ private <T> DurableFuture<T> runInChildContextAsync(
346346
var operationId = nextOperationId();
347347

348348
var operation = new ChildContextOperation<>(
349-
new OperationIdentifier(operationId, name, OperationType.CONTEXT, subType),
349+
OperationIdentifier.of(operationId, name, OperationType.CONTEXT, subType),
350350
func,
351351
typeToken,
352352
getDurableConfig().getSerDes(),

sdk/src/main/java/software/amazon/lambda/durable/model/OperationIdentifier.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,13 @@
55
import software.amazon.awssdk.services.lambda.model.OperationType;
66

77
public record OperationIdentifier(
8-
String operationId, String name, OperationType operationType, OperationSubType subType) {}
8+
String operationId, String name, OperationType operationType, OperationSubType subType) {
9+
public static OperationIdentifier of(String operationId, String name, OperationType type) {
10+
return new OperationIdentifier(operationId, name, type, null);
11+
}
12+
13+
public static OperationIdentifier of(
14+
String operationId, String name, OperationType type, OperationSubType subType) {
15+
return new OperationIdentifier(operationId, name, type, subType);
16+
}
17+
}

sdk/src/test/java/software/amazon/lambda/durable/operation/BaseDurableOperationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class BaseDurableOperationTest {
4747
private static final Operation OPERATION = Operation.builder().build();
4848
private static final OperationType OPERATION_TYPE = OperationType.STEP;
4949
private static final OperationIdentifier OPERATION_IDENTIFIER =
50-
new OperationIdentifier(OPERATION_ID, OPERATION_NAME, OPERATION_TYPE, null);
50+
OperationIdentifier.of(OPERATION_ID, OPERATION_NAME, OPERATION_TYPE);
5151
private static final TypeToken<String> RESULT_TYPE = TypeToken.get(String.class);
5252
private static final SerDes SER_DES = new JacksonSerDes();
5353
private static final String RESULT = "name";

sdk/src/test/java/software/amazon/lambda/durable/operation/CallbackOperationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class CallbackOperationTest {
3434
private static final String OPERATION_ID = "1";
3535
private static final String OPERATION_NAME = "approval";
3636
private static final OperationIdentifier OPERATION_IDENTIFIER =
37-
new OperationIdentifier(OPERATION_ID, OPERATION_NAME, OperationType.CALLBACK, null);
37+
OperationIdentifier.of(OPERATION_ID, OPERATION_NAME, OperationType.CALLBACK);
3838

3939
private DurableContext durableContext;
4040

sdk/src/test/java/software/amazon/lambda/durable/operation/ChildContextOperationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ private DurableConfig createConfig() {
5252
}
5353

5454
private static final OperationIdentifier OPERATION_IDENTIFIER =
55-
new OperationIdentifier("1", "test-context", OperationType.CONTEXT, OperationSubType.RUN_IN_CHILD_CONTEXT);
55+
OperationIdentifier.of("1", "test-context", OperationType.CONTEXT, OperationSubType.RUN_IN_CHILD_CONTEXT);
5656

5757
private ChildContextOperation<String> createOperation(Function<DurableContext, String> func) {
5858
return new ChildContextOperation<>(

sdk/src/test/java/software/amazon/lambda/durable/operation/InvokeOperationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class InvokeOperationTest {
3131
private static final String OPERATION_ID = "2";
3232
private static final String OPERATION_NAME = "test-invoke";
3333
private static final OperationIdentifier OPERATION_IDENTIFIER =
34-
new OperationIdentifier(OPERATION_ID, OPERATION_NAME, OperationType.CHAINED_INVOKE, null);
34+
OperationIdentifier.of(OPERATION_ID, OPERATION_NAME, OperationType.CHAINED_INVOKE);
3535

3636
private ExecutionManager executionManager;
3737
private DurableContext durableContext;

sdk/src/test/java/software/amazon/lambda/durable/operation/StepOperationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class StepOperationTest {
3232
private static final String OPERATION_NAME = "test-step";
3333
private static final String RESULT = "result";
3434
private static final OperationIdentifier OPERATION_IDENTIFIER =
35-
new OperationIdentifier(OPERATION_ID, OPERATION_NAME, OperationType.STEP, null);
35+
OperationIdentifier.of(OPERATION_ID, OPERATION_NAME, OperationType.STEP);
3636
private ExecutionManager executionManager;
3737
private DurableContext durableContext;
3838

sdk/src/test/java/software/amazon/lambda/durable/operation/WaitOperationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class WaitOperationTest {
2525
private static final String CONTEXT_ID = "handler";
2626
private static final String OPERATION_NAME = "test-wait";
2727
private static final OperationIdentifier OPERATION_IDENTIFIER =
28-
new OperationIdentifier(OPERATION_ID, OPERATION_NAME, OperationType.WAIT, null);
28+
OperationIdentifier.of(OPERATION_ID, OPERATION_NAME, OperationType.WAIT);
2929
private ExecutionManager executionManager;
3030
private DurableContext durableContext;
3131

0 commit comments

Comments
 (0)