Skip to content

Commit 045452f

Browse files
committed
remove @step retriesAllowed
StepOptions verification
1 parent 4cb9dba commit 045452f

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

transact/src/main/java/dev/dbos/transact/workflow/Step.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@
1010
public @interface Step {
1111
String name() default "";
1212

13-
boolean retriesAllowed() default false;
13+
int maxAttempts() default 1;
1414

1515
double intervalSeconds() default StepOptions.DEFAULT_INTERVAL_SECONDS;
1616

17-
int maxAttempts() default 3;
18-
1917
double backOffRate() default StepOptions.DEFAULT_BACKOFF;
2018
}

transact/src/main/java/dev/dbos/transact/workflow/StepOptions.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@ public record StepOptions(
1212
public static final double DEFAULT_INTERVAL_SECONDS = 1.0;
1313
public static final double DEFAULT_BACKOFF = 2.0;
1414

15+
public StepOptions {
16+
if (maxAttempts < 1) {
17+
throw new IllegalArgumentException("maxAttempts must be greater than or equal to one");
18+
}
19+
if (retryInterval.isNegative() || retryInterval.isZero()) {
20+
throw new IllegalArgumentException("retryInterval must be positive");
21+
}
22+
if (backOffRate < 1.0) {
23+
throw new IllegalArgumentException("backOffRate must be greater than or equal to 1.0");
24+
}
25+
}
26+
1527
public StepOptions(String name) {
1628
this(
1729
name,
@@ -22,7 +34,7 @@ public StepOptions(String name) {
2234

2335
public static StepOptions create(Step stepTag, Method method) {
2436
var name = stepTag.name().isEmpty() ? method.getName() : stepTag.name();
25-
var maxAttempts = stepTag.retriesAllowed() ? stepTag.maxAttempts() : 1;
37+
var maxAttempts = stepTag.maxAttempts() < 1 ? 1 : stepTag.maxAttempts();
2638
var interval = Duration.ofMillis((long) (stepTag.intervalSeconds() * 1000));
2739
return new StepOptions(name, maxAttempts, interval, stepTag.backOffRate());
2840
}

0 commit comments

Comments
 (0)