Skip to content

Commit 596badb

Browse files
devhawkCopilot
andcommitted
improve javadocs
Co-authored-by: Copilot <copilot@github.com>
1 parent 7d0827f commit 596badb

2 files changed

Lines changed: 114 additions & 33 deletions

File tree

transact/src/main/java/dev/dbos/transact/StartWorkflowOptions.java

Lines changed: 114 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,34 @@
1414
import org.jspecify.annotations.Nullable;
1515

1616
/**
17-
* Options for starting a workflow, including: Assigning the workflow idempotency ID Enqueuing, with
18-
* options Setting a timeout.
17+
* Options for starting a workflow instance.
18+
*
19+
* <p>This record encapsulates configuration for workflow execution, including:
20+
*
21+
* <ul>
22+
* <li>Idempotency and tracking via a unique workflow ID
23+
* <li>Timeout and deadline management
24+
* <li>Queue assignment, deduplication, priority, and partitioning
25+
* <li>Optional execution delay and application version targeting
26+
* </ul>
1927
*
2028
* @param workflowId The unique identifier for the workflow instance. Used for idempotency and
21-
* tracking.
29+
* tracking. May be null.
2230
* @param timeout The timeout configuration specifying how long the workflow may run before
23-
* expiring; this is promoted to a deadline at execution time.
31+
* expiring. Promoted to a deadline at execution time. May be null.
2432
* @param deadline The absolute time by which the workflow must start or complete before being
25-
* canceled, if timeout is also set the deadline is derived from the timeout.
26-
* @param queueName An optional name of the queue to which the workflow should be enqueued for
27-
* execution.
28-
* @param deduplicationId If `queueName` is specified, an optional ID used to prevent duplicate
29-
* enqueued workflows.
30-
* @param priority If `queueName` is specified and refers to a queue with priority enabled, the
31-
* priority to assign.
32-
* @param queuePartitionKey If `queueName` is specified, an optional partition key used to
33-
* distribute workflows across queue partitions for load balancing and ordered processing.
33+
* canceled. If both timeout and deadline are set, the earlier is used. May be null.
34+
* @param queueName Optional name of the queue to which the workflow should be enqueued for
35+
* execution. May be null.
36+
* @param deduplicationId If {@code queueName} is specified, an optional ID used to prevent
37+
* duplicate enqueued workflows. May be null.
38+
* @param priority If {@code queueName} is specified and refers to a queue with priority enabled,
39+
* the priority to assign. May be null.
40+
* @param queuePartitionKey If {@code queueName} is specified, an optional partition key used to
41+
* distribute workflows across queue partitions for load balancing and ordered processing. May
42+
* be null.
43+
* @param delay Optional delay before the workflow starts executing. May be null.
44+
* @param appVersion Optional application version to target for workflow execution. May be null.
3445
*/
3546
public record StartWorkflowOptions(
3647
@Nullable String workflowId,
@@ -73,22 +84,35 @@ public record StartWorkflowOptions(
7384
}
7485
}
7586

76-
/** Construct with default options */
87+
/** Construct with default options (all fields null). */
7788
public StartWorkflowOptions() {
7889
this(null, null, null, null, null, null, null, null, null);
7990
}
8091

81-
/** Construct with a specified workflow ID */
92+
/**
93+
* Construct with a specified workflow ID.
94+
*
95+
* @param workflowId the workflow ID to assign
96+
*/
8297
public StartWorkflowOptions(String workflowId) {
8398
this(workflowId, null, null, null, null, null, null, null, null);
8499
}
85100

86-
/** Construct with a specified queue */
101+
/**
102+
* Construct with a specified queue.
103+
*
104+
* @param queue the queue to assign the workflow to
105+
*/
87106
public StartWorkflowOptions(@NonNull Queue queue) {
88107
this(null, null, null, queue.name(), null, null, null, null, null);
89108
}
90109

91-
/** Produces a new StartWorkflowOptions that overrides the ID assigned to the started workflow */
110+
/**
111+
* Returns a new StartWorkflowOptions with the specified workflow ID.
112+
*
113+
* @param workflowId the workflow ID to assign
114+
* @return a new StartWorkflowOptions with the updated workflow ID
115+
*/
92116
public @NonNull StartWorkflowOptions withWorkflowId(@Nullable String workflowId) {
93117
return new StartWorkflowOptions(
94118
workflowId,
@@ -102,7 +126,12 @@ public StartWorkflowOptions(@NonNull Queue queue) {
102126
this.appVersion);
103127
}
104128

105-
/** Produces a new StartWorkflowOptions that overrides timeout value for the started workflow */
129+
/**
130+
* Returns a new StartWorkflowOptions with the specified timeout.
131+
*
132+
* @param timeout the timeout to assign
133+
* @return a new StartWorkflowOptions with the updated timeout
134+
*/
106135
public @NonNull StartWorkflowOptions withTimeout(@Nullable Timeout timeout) {
107136
return new StartWorkflowOptions(
108137
this.workflowId,
@@ -116,22 +145,42 @@ public StartWorkflowOptions(@NonNull Queue queue) {
116145
this.appVersion);
117146
}
118147

119-
/** Produces a new StartWorkflowOptions that overrides timeout value for the started workflow */
148+
/**
149+
* Returns a new StartWorkflowOptions with the specified timeout duration.
150+
*
151+
* @param timeout the timeout duration to assign
152+
* @return a new StartWorkflowOptions with the updated timeout
153+
*/
120154
public @NonNull StartWorkflowOptions withTimeout(@NonNull Duration timeout) {
121155
return withTimeout(Timeout.of(timeout));
122156
}
123157

124-
/** Produces a new StartWorkflowOptions that overrides timeout value for the started workflow */
158+
/**
159+
* Returns a new StartWorkflowOptions with the specified timeout value and unit.
160+
*
161+
* @param value the timeout value
162+
* @param unit the time unit for the timeout
163+
* @return a new StartWorkflowOptions with the updated timeout
164+
*/
125165
public @NonNull StartWorkflowOptions withTimeout(long value, @NonNull TimeUnit unit) {
126166
return withTimeout(Duration.ofNanos(unit.toNanos(value)));
127167
}
128168

129-
/** Produces a new StartWorkflowOptions that removes the timeout behavior */
169+
/**
170+
* Returns a new StartWorkflowOptions with no timeout (disables timeout behavior).
171+
*
172+
* @return a new StartWorkflowOptions with timeout disabled
173+
*/
130174
public @NonNull StartWorkflowOptions withNoTimeout() {
131175
return withTimeout(Timeout.none());
132176
}
133177

134-
/** Produces a new StartWorkflowOptions that overrides deadline value for the started workflow */
178+
/**
179+
* Returns a new StartWorkflowOptions with the specified deadline.
180+
*
181+
* @param deadline the absolute deadline to assign
182+
* @return a new StartWorkflowOptions with the updated deadline
183+
*/
135184
public @NonNull StartWorkflowOptions withDeadline(@Nullable Instant deadline) {
136185
return new StartWorkflowOptions(
137186
this.workflowId,
@@ -145,7 +194,12 @@ public StartWorkflowOptions(@NonNull Queue queue) {
145194
this.appVersion);
146195
}
147196

148-
/** Produces a new StartWorkflowOptions that assigns the started workflow to a queue */
197+
/**
198+
* Returns a new StartWorkflowOptions with the specified queue name.
199+
*
200+
* @param queue the queue name to assign
201+
* @return a new StartWorkflowOptions with the updated queue name
202+
*/
149203
public @NonNull StartWorkflowOptions withQueue(@Nullable String queue) {
150204
return new StartWorkflowOptions(
151205
this.workflowId,
@@ -159,14 +213,22 @@ public StartWorkflowOptions(@NonNull Queue queue) {
159213
this.appVersion);
160214
}
161215

162-
/** Produces a new StartWorkflowOptions that assigns the started workflow to a queue */
216+
/**
217+
* Returns a new StartWorkflowOptions with the specified queue.
218+
*
219+
* @param queue the queue to assign
220+
* @return a new StartWorkflowOptions with the updated queue name
221+
*/
163222
public @NonNull StartWorkflowOptions withQueue(@NonNull Queue queue) {
164223
return withQueue(queue.name());
165224
}
166225

167226
/**
168-
* Produces a new StartWorkflowOptions that assigns a queue deduplication ID. Note that the queue
169-
* must also be specified.
227+
* Returns a new StartWorkflowOptions with the specified queue deduplication ID. Note: The queue
228+
* must also be specified for deduplication to take effect.
229+
*
230+
* @param deduplicationId the deduplication ID to assign
231+
* @return a new StartWorkflowOptions with the updated deduplication ID
170232
*/
171233
public @NonNull StartWorkflowOptions withDeduplicationId(@Nullable String deduplicationId) {
172234
return new StartWorkflowOptions(
@@ -182,8 +244,11 @@ public StartWorkflowOptions(@NonNull Queue queue) {
182244
}
183245

184246
/**
185-
* Produces a new StartWorkflowOptions that assigns a queue priority. Note that the queue must
186-
* also be specified and have prioritization enabled
247+
* Returns a new StartWorkflowOptions with the specified queue priority. Note: The queue must be
248+
* specified and have prioritization enabled.
249+
*
250+
* @param priority the priority to assign
251+
* @return a new StartWorkflowOptions with the updated priority
187252
*/
188253
public @NonNull StartWorkflowOptions withPriority(@Nullable Integer priority) {
189254
return new StartWorkflowOptions(
@@ -198,7 +263,12 @@ public StartWorkflowOptions(@NonNull Queue queue) {
198263
this.appVersion);
199264
}
200265

201-
/** Produces a new StartWorkflowOptions that assigns a queue partition key */
266+
/**
267+
* Returns a new StartWorkflowOptions with the specified queue partition key.
268+
*
269+
* @param queuePartitionKey the partition key to assign
270+
* @return a new StartWorkflowOptions with the updated partition key
271+
*/
202272
public @NonNull StartWorkflowOptions withQueuePartitionKey(@Nullable String queuePartitionKey) {
203273
return new StartWorkflowOptions(
204274
this.workflowId,
@@ -213,7 +283,10 @@ public StartWorkflowOptions(@NonNull Queue queue) {
213283
}
214284

215285
/**
216-
* Produces a new StartWorkflowOptions that assigns a delay before the workflow starts executing
286+
* Returns a new StartWorkflowOptions with the specified delay before execution.
287+
*
288+
* @param delay the delay duration to assign
289+
* @return a new StartWorkflowOptions with the updated delay
217290
*/
218291
public @NonNull StartWorkflowOptions withDelay(@Nullable Duration delay) {
219292
return new StartWorkflowOptions(
@@ -228,7 +301,12 @@ public StartWorkflowOptions(@NonNull Queue queue) {
228301
this.appVersion);
229302
}
230303

231-
/** Produces a new StartWorkflowOptions that assigns an app version */
304+
/**
305+
* Returns a new StartWorkflowOptions with the specified application version.
306+
*
307+
* @param appVersion the application version to assign
308+
* @return a new StartWorkflowOptions with the updated application version
309+
*/
232310
public @NonNull StartWorkflowOptions withAppVersion(@Nullable String appVersion) {
233311
return new StartWorkflowOptions(
234312
this.workflowId,
@@ -242,7 +320,11 @@ public StartWorkflowOptions(@NonNull Queue queue) {
242320
appVersion);
243321
}
244322

245-
/** Get the assigned workflow ID, replacing empty with null */
323+
/**
324+
* Get the assigned workflow ID, replacing empty with null.
325+
*
326+
* @return the workflow ID, or null if empty or not set
327+
*/
246328
@Override
247329
public @Nullable String workflowId() {
248330
return workflowId != null && workflowId.isEmpty() ? null : workflowId;

transact/src/main/kotlin/dev/dbos/transact/DBOSExtensions.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import dev.dbos.transact.workflow.WorkflowHandle
1212
// interfaces (like ThrowingSupplier), so such an extension would be unreachable — the Java member
1313
// wins before the extension is considered. This does not affect overloads that also take a
1414
// StartWorkflowOptions parameter, since those signatures are distinct from any Java member.
15-
// For the no-options case, we provide beginWorkflow as a uniquely-named alternative.
1615

1716
/**
1817
* Starts a workflow using trailing lambda syntax, with the given [options].

0 commit comments

Comments
 (0)