Skip to content
Merged
4 changes: 3 additions & 1 deletion transact/src/main/java/dev/dbos/transact/DBOSClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,9 @@ dev.dbos.transact.EnqueueOptions toEnqueueOptions() {
assumedRole,
authenticatedRoles,
attributes,
applicationName);
applicationName,
// workflowIdReusePolicy: this deprecated type has none.
null);
}
}

Expand Down
87 changes: 71 additions & 16 deletions transact/src/main/java/dev/dbos/transact/EnqueueOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import dev.dbos.transact.workflow.QueueName;
import dev.dbos.transact.workflow.SerializationStrategy;
import dev.dbos.transact.workflow.Timeout;
import dev.dbos.transact.workflow.WorkflowIdReusePolicy;

import java.time.Duration;
import java.time.Instant;
Expand Down Expand Up @@ -75,6 +76,10 @@
* @param applicationName The application that owns the enqueued workflow, and whose executors
* therefore dequeue and run it. Optional; defaults to the enqueueing application. Set it to
* enqueue work for a peer sharing this system database.
* @param workflowIdReusePolicy What to do when a workflow with {@code workflowId} already exists,
* whatever its status: attach to it ({@link WorkflowIdReusePolicy#RETURN_EXISTING}, the
* default) or refuse with {@link dev.dbos.transact.exceptions.DBOSWorkflowIdInUseException}
* ({@link WorkflowIdReusePolicy#REJECT}). May be null.
*/
public record EnqueueOptions(
@NonNull String workflowName,
Expand All @@ -94,7 +99,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 {
Objects.requireNonNull(workflowName, "workflowName must not be null");
Expand Down Expand Up @@ -234,6 +240,7 @@ public EnqueueOptions(
null,
null,
null,
null,
null);
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/**
* Returns a new EnqueueOptions with the specified workflow ID reuse policy.
*
* @param workflowIdReusePolicy what to do when a workflow with this ID already exists: {@link
* WorkflowIdReusePolicy#RETURN_EXISTING} (the default) attaches to it, {@link
* WorkflowIdReusePolicy#REJECT} refuses with {@link
* dev.dbos.transact.exceptions.DBOSWorkflowIdInUseException}
* @return a new EnqueueOptions with the updated policy
*/
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);
}

/**
Expand Down Expand Up @@ -722,6 +776,7 @@ public EnqueueOptions(
this.assumedRole,
this.authenticatedRoles,
this.attributes,
applicationName);
applicationName,
this.workflowIdReusePolicy);
}
}
Loading
Loading