You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var future1 = context.stepAsync("step1", ()-> failsAndRetries());
19
-
var result = context.step("step2", ()-> future1.get() +"-processed");
18
+
var future1 = context.stepAsync("step1", stepCtx-> failsAndRetries());
19
+
var result = context.step("step2", stepCtx-> future1.get() +"-processed");
20
20
```
21
21
22
22
**Problem:** Simple thread counting fails because step2's thread would stay registered while blocked on `future1.get()`, preventing suspension during step1's retry delay.
@@ -78,11 +78,11 @@ Control how steps behave when interrupted mid-execution:
78
78
```java
79
79
// Default: at-least-once per retry (step may re-run if interrupted)
80
80
var result = ctx.step("idempotent-update", Result.class,
81
-
()-> database.upsert(record));
81
+
stepCtx-> database.upsert(record));
82
82
83
83
// At-most-once per retry
84
84
var result = ctx.step("send-email", Result.class,
85
-
()-> emailService.send(notification),
85
+
stepCtx-> emailService.send(notification),
86
86
StepConfig.builder()
87
87
.semantics(StepSemantics.AT_MOST_ONCE_PER_RETRY)
88
88
.build());
@@ -98,7 +98,7 @@ To achieve step-level at-most-once semantics, combine with a no-retry strategy:
98
98
```java
99
99
// True at-most-once: step executes at most once, ever
100
100
var result = ctx.step("charge-payment", Result.class,
101
-
()-> paymentService.charge(amount),
101
+
stepCtx-> paymentService.charge(amount),
102
102
StepConfig.builder()
103
103
.semantics(StepSemantics.AT_MOST_ONCE_PER_RETRY)
104
104
.retryStrategy(RetryStrategies.Presets.NO_RETRY)
@@ -113,10 +113,10 @@ When a step returns a parameterized type like `List<User>`, use `TypeToken` to p
113
113
114
114
```java
115
115
var users = ctx.step("fetch-users", newTypeToken<List<User>>() {},
116
-
()-> userService.getAllUsers());
116
+
stepCtx-> userService.getAllUsers());
117
117
118
118
var orderMap = ctx.step("fetch-orders", newTypeToken<Map<String, Order>>() {},
119
-
()-> orderService.getOrdersByCustomer());
119
+
stepCtx-> orderService.getOrdersByCustomer());
120
120
```
121
121
122
122
This is needed for the SDK to deserialize a checkpointed result and get the exact type to reconstruct. See [TypeToken and Type Erasure](docs/internal-design.md#typetoken-and-type-erasure) for technical details.
0 commit comments