Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 120 additions & 19 deletions transact/src/main/java/dev/dbos/transact/DBOSClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import dev.dbos.transact.workflow.VersionInfo;
import dev.dbos.transact.workflow.WorkflowDelay;
import dev.dbos.transact.workflow.WorkflowHandle;
import dev.dbos.transact.workflow.WorkflowIdReusePolicy;
import dev.dbos.transact.workflow.WorkflowSchedule;
import dev.dbos.transact.workflow.WorkflowStatus;
import dev.dbos.transact.workflow.internal.InternalWorkflows;
Expand Down Expand Up @@ -334,6 +335,7 @@ public void close() {
* @param authenticatedRoles The authenticated roles to associate with the workflow. Optional.
* @param attributes Custom JSON-serializable attributes to attach to the workflow. Optional.
* @param applicationName The application that owns the enqueued workflow. Optional.
* @param workflowIdReusePolicy What to do when a workflow with this ID already exists. Optional.
*/
@Deprecated(since = "1.1", forRemoval = true)
public record EnqueueOptions(
Expand All @@ -354,7 +356,8 @@ public record EnqueueOptions(
@Nullable String assumedRole,
@Nullable List<String> authenticatedRoles,
@Nullable Map<String, Object> attributes,
@Nullable String applicationName) {
@Nullable String applicationName,
@Nullable WorkflowIdReusePolicy workflowIdReusePolicy) {

public EnqueueOptions {
if (nullableIsEmpty(workflowName)) {
Expand Down Expand Up @@ -440,6 +443,7 @@ public EnqueueOptions(@NonNull String workflowName, @NonNull String queueName) {
null,
null,
null,
null,
null);
}

Expand Down Expand Up @@ -483,6 +487,52 @@ public EnqueueOptions(
assumedRole,
authenticatedRoles,
attributes,
null,
null);
}

/**
* Constructs options with no workflow ID reuse policy, which attaches to a workflow that
* already has this ID.
*/
public EnqueueOptions(
@NonNull String workflowName,
@Nullable String className,
@Nullable String instanceName,
@NonNull String queueName,
@Nullable String workflowId,
@Nullable String appVersion,
@Nullable Duration timeout,
@Nullable Instant deadline,
@Nullable String deduplicationId,
@Nullable Integer priority,
@Nullable String queuePartitionKey,
@Nullable Duration delay,
@Nullable SerializationStrategy serialization,
@Nullable String authenticatedUser,
@Nullable String assumedRole,
@Nullable List<String> authenticatedRoles,
@Nullable Map<String, Object> attributes,
@Nullable String applicationName) {
this(
workflowName,
className,
instanceName,
queueName,
workflowId,
appVersion,
timeout,
deadline,
deduplicationId,
priority,
queuePartitionKey,
delay,
serialization,
authenticatedUser,
assumedRole,
authenticatedRoles,
attributes,
applicationName,
null);
}

Expand All @@ -506,6 +556,7 @@ public EnqueueOptions(
null,
null,
null,
null,
null);
}

Expand Down Expand Up @@ -534,7 +585,8 @@ public EnqueueOptions(
this.assumedRole,
this.authenticatedRoles,
this.attributes,
this.applicationName);
this.applicationName,
this.workflowIdReusePolicy);
}

/**
Expand Down Expand Up @@ -563,7 +615,8 @@ public EnqueueOptions(
this.assumedRole,
this.authenticatedRoles,
this.attributes,
this.applicationName);
this.applicationName,
this.workflowIdReusePolicy);
}

/**
Expand Down Expand Up @@ -594,7 +647,8 @@ public EnqueueOptions(
this.assumedRole,
this.authenticatedRoles,
this.attributes,
this.applicationName);
this.applicationName,
this.workflowIdReusePolicy);
}

/**
Expand Down Expand Up @@ -623,7 +677,8 @@ public EnqueueOptions(
this.assumedRole,
this.authenticatedRoles,
this.attributes,
this.applicationName);
this.applicationName,
this.workflowIdReusePolicy);
}

/**
Expand Down Expand Up @@ -652,7 +707,8 @@ public EnqueueOptions(
this.assumedRole,
this.authenticatedRoles,
this.attributes,
this.applicationName);
this.applicationName,
this.workflowIdReusePolicy);
}

/**
Expand Down Expand Up @@ -681,7 +737,8 @@ public EnqueueOptions(
this.assumedRole,
this.authenticatedRoles,
this.attributes,
this.applicationName);
this.applicationName,
this.workflowIdReusePolicy);
}

/**
Expand Down Expand Up @@ -710,7 +767,8 @@ public EnqueueOptions(
this.assumedRole,
this.authenticatedRoles,
this.attributes,
this.applicationName);
this.applicationName,
this.workflowIdReusePolicy);
}

/**
Expand Down Expand Up @@ -738,7 +796,8 @@ public EnqueueOptions(
this.assumedRole,
this.authenticatedRoles,
this.attributes,
this.applicationName);
this.applicationName,
this.workflowIdReusePolicy);
}

/**
Expand Down Expand Up @@ -768,7 +827,8 @@ public EnqueueOptions(
this.assumedRole,
this.authenticatedRoles,
this.attributes,
this.applicationName);
this.applicationName,
this.workflowIdReusePolicy);
}

/**
Expand Down Expand Up @@ -797,7 +857,8 @@ public EnqueueOptions(
this.assumedRole,
this.authenticatedRoles,
this.attributes,
this.applicationName);
this.applicationName,
this.workflowIdReusePolicy);
}

/**
Expand Down Expand Up @@ -828,7 +889,8 @@ public EnqueueOptions(
this.assumedRole,
this.authenticatedRoles,
this.attributes,
this.applicationName);
this.applicationName,
this.workflowIdReusePolicy);
}

/**
Expand Down Expand Up @@ -856,7 +918,8 @@ public EnqueueOptions(
this.assumedRole,
this.authenticatedRoles,
this.attributes,
this.applicationName);
this.applicationName,
this.workflowIdReusePolicy);
}

/**
Expand Down Expand Up @@ -884,7 +947,8 @@ public EnqueueOptions(
assumedRole,
this.authenticatedRoles,
this.attributes,
this.applicationName);
this.applicationName,
this.workflowIdReusePolicy);
}

/**
Expand Down Expand Up @@ -912,7 +976,8 @@ public EnqueueOptions(
this.assumedRole,
authenticatedRoles != null ? List.of(authenticatedRoles) : null,
this.attributes,
this.applicationName);
this.applicationName,
this.workflowIdReusePolicy);
}

/**
Expand Down Expand Up @@ -942,7 +1007,8 @@ public EnqueueOptions(
this.assumedRole,
authenticatedRoles != null ? List.of(authenticatedRoles) : null,
this.attributes,
this.applicationName);
this.applicationName,
this.workflowIdReusePolicy);
}

/**
Expand Down Expand Up @@ -972,7 +1038,8 @@ public EnqueueOptions(
this.assumedRole,
this.authenticatedRoles,
attributes,
this.applicationName);
this.applicationName,
this.workflowIdReusePolicy);
}

/**
Expand Down Expand Up @@ -1004,7 +1071,40 @@ public EnqueueOptions(
this.assumedRole,
this.authenticatedRoles,
this.attributes,
applicationName);
applicationName,
this.workflowIdReusePolicy);
}

/**
* Specify what enqueueing does when a workflow with this ID already exists.
*
* @param workflowIdReusePolicy {@link WorkflowIdReusePolicy#RETURN_EXISTING} (the default)
* attaches to it, {@link WorkflowIdReusePolicy#REJECT} refuses with {@link
* dev.dbos.transact.exceptions.DBOSWorkflowIdInUseException}
* @return New `EnqueueOptions` with the policy set
*/
public @NonNull EnqueueOptions withWorkflowIdReusePolicy(
@Nullable WorkflowIdReusePolicy workflowIdReusePolicy) {
return new EnqueueOptions(
this.workflowName,
this.className,
this.instanceName,
this.queueName,
this.workflowId,
this.appVersion,
this.timeout,
this.deadline,
this.deduplicationId,
this.priority,
this.queuePartitionKey,
this.delay,
this.serialization,
this.authenticatedUser,
this.assumedRole,
this.authenticatedRoles,
this.attributes,
this.applicationName,
workflowIdReusePolicy);
}

dev.dbos.transact.EnqueueOptions toEnqueueOptions() {
Expand All @@ -1026,7 +1126,8 @@ dev.dbos.transact.EnqueueOptions toEnqueueOptions() {
assumedRole,
authenticatedRoles,
attributes,
applicationName);
applicationName,
workflowIdReusePolicy);
}
}

Expand Down
Loading
Loading