Skip to content
Draft
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
28 changes: 28 additions & 0 deletions transact/src/main/java/dev/dbos/transact/DBOS.java
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,8 @@ public <E extends Exception> void runStep(
* will be resumed in the default execution context
* @return A handle to the resumed workflow
* @throws IllegalStateException if called before DBOS is launched
* @throws IllegalArgumentException if called from inside the workflow being resumed, or one of
* its steps: a workflow can't resume itself. Nothing is resumed.
*/
@SuppressWarnings("unchecked")
public <T, E extends Exception> @NonNull WorkflowHandle<T, E> resumeWorkflow(
Expand All @@ -892,6 +894,8 @@ public <E extends Exception> void runStep(
* @param workflowId ID of the workflow to resume; must not be null
* @return A handle to the resumed workflow
* @throws IllegalStateException if called before DBOS is launched
* @throws IllegalArgumentException if called from inside the workflow being resumed, or one of
* its steps: a workflow can't resume itself. Nothing is resumed.
*/
public <T, E extends Exception> @NonNull WorkflowHandle<T, E> resumeWorkflow(
@NonNull String workflowId) {
Expand All @@ -909,6 +913,8 @@ public <E extends Exception> void runStep(
* workflows will be resumed in the default execution context
* @return A list of handles to the resumed workflows
* @throws IllegalStateException if called before DBOS is launched
* @throws IllegalArgumentException if called from inside one of the workflows being resumed, or
* one of its steps: a workflow can't resume itself. Nothing is resumed.
*/
public @NonNull List<WorkflowHandle<Object, Exception>> resumeWorkflows(
@NonNull List<String> workflowIds, @Nullable String queueName) {
Expand All @@ -924,6 +930,8 @@ public <E extends Exception> void runStep(
* @param workflowIds a list of workflow IDs to resume; must not be null
* @return A list of handles to the resumed workflows
* @throws IllegalStateException if called before DBOS is launched
* @throws IllegalArgumentException if called from inside one of the workflows being resumed, or
* one of its steps: a workflow can't resume itself. Nothing is resumed.
*/
public @NonNull List<WorkflowHandle<Object, Exception>> resumeWorkflows(
@NonNull List<String> workflowIds) {
Expand All @@ -937,6 +945,8 @@ public <E extends Exception> void runStep(
*
* @param workflowId ID of the workflow to cancel
* @throws IllegalStateException if called before DBOS is launched
* @throws IllegalArgumentException if called from inside the workflow being cancelled, or one of
* its steps: a workflow can't cancel itself. Nothing is cancelled.
*/
public void cancelWorkflow(@NonNull String workflowId) {
cancelWorkflows(List.of(workflowId), false);
Expand All @@ -948,6 +958,9 @@ public void cancelWorkflow(@NonNull String workflowId) {
* @param workflowId ID of the workflow to cancel
* @param cancelChildren if true, recursively cancel all descendant workflows
* @throws IllegalStateException if called before DBOS is launched
* @throws IllegalArgumentException if called from inside the workflow being cancelled, or one of
* its steps, or, when {@code cancelChildren}, from inside one of its descendants: a workflow
* can't cancel itself or a tree it belongs to. Nothing is cancelled.
*/
public void cancelWorkflow(@NonNull String workflowId, boolean cancelChildren) {
cancelWorkflows(List.of(workflowId), cancelChildren);
Expand All @@ -959,6 +972,8 @@ public void cancelWorkflow(@NonNull String workflowId, boolean cancelChildren) {
*
* @param workflowIds a list of workflow IDs to cancel; must not be null
* @throws IllegalStateException if called before DBOS is launched
* @throws IllegalArgumentException if called from inside one of the workflows being cancelled, or
* one of its steps: a workflow can't cancel itself. Nothing is cancelled.
*/
public void cancelWorkflows(@NonNull List<String> workflowIds) {
cancelWorkflows(workflowIds, false);
Expand All @@ -970,6 +985,9 @@ public void cancelWorkflows(@NonNull List<String> workflowIds) {
* @param workflowIds a list of workflow IDs to cancel; must not be null
* @param cancelChildren if true, recursively cancel all descendant workflows
* @throws IllegalStateException if called before DBOS is launched
* @throws IllegalArgumentException if called from inside one of the workflows being cancelled, or
* one of its steps, or, when {@code cancelChildren}, from inside one of their descendants: a
* workflow can't cancel itself or a tree it belongs to. Nothing is cancelled.
*/
public void cancelWorkflows(@NonNull List<String> workflowIds, boolean cancelChildren) {
ensureLaunched("cancelWorkflows").cancelWorkflows(workflowIds, cancelChildren);
Expand All @@ -981,6 +999,8 @@ public void cancelWorkflows(@NonNull List<String> workflowIds, boolean cancelChi
*
* @param workflowId ID of the workflow to delete; must not be null
* @throws IllegalStateException if called before DBOS is launched
* @throws IllegalArgumentException if called from inside the workflow being deleted, or one of
* its steps: a workflow can't delete itself. Nothing is deleted.
*/
public void deleteWorkflow(@NonNull String workflowId) {
deleteWorkflows(List.of(workflowId), false);
Expand All @@ -994,6 +1014,9 @@ public void deleteWorkflow(@NonNull String workflowId) {
* @param deleteChildren if true, also delete any child workflows; if false, preserve child
* workflows
* @throws IllegalStateException if called before DBOS is launched
* @throws IllegalArgumentException if called from inside the workflow being deleted, or one of
* its steps, or, when {@code deleteChildren}, from inside one of its descendants: a workflow
* can't delete itself or a tree it belongs to. Nothing is deleted.
*/
public void deleteWorkflow(@NonNull String workflowId, boolean deleteChildren) {
deleteWorkflows(List.of(workflowId), deleteChildren);
Expand All @@ -1005,6 +1028,8 @@ public void deleteWorkflow(@NonNull String workflowId, boolean deleteChildren) {
*
* @param workflowIds a list of workflow IDs to delete; must not be null
* @throws IllegalStateException if called before DBOS is launched
* @throws IllegalArgumentException if called from inside one of the workflows being deleted, or
* one of its steps: a workflow can't delete itself. Nothing is deleted.
*/
public void deleteWorkflows(@NonNull List<String> workflowIds) {
deleteWorkflows(workflowIds, false);
Expand All @@ -1018,6 +1043,9 @@ public void deleteWorkflows(@NonNull List<String> workflowIds) {
* @param deleteChildren if true, also delete any child workflows; if false, preserve child
* workflows
* @throws IllegalStateException if called before DBOS is launched
* @throws IllegalArgumentException if called from inside one of the workflows being deleted, or
* one of its steps, or, when {@code deleteChildren}, from inside one of their descendants: a
* workflow can't delete itself or a tree it belongs to. Nothing is deleted.
*/
public void deleteWorkflows(@NonNull List<String> workflowIds, boolean deleteChildren) {
ensureLaunched("deleteWorkflows").deleteWorkflows(workflowIds, deleteChildren);
Expand Down
8 changes: 4 additions & 4 deletions transact/src/main/java/dev/dbos/transact/DBOSClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -1597,7 +1597,7 @@ public void cancelWorkflows(@NonNull List<String> workflowIds) {
* @param cancelChildren if true, recursively cancel all descendant workflows
*/
public void cancelWorkflows(@NonNull List<String> workflowIds, boolean cancelChildren) {
systemDatabase.cancelWorkflows(workflowIds, cancelChildren);
systemDatabase.cancelWorkflows(workflowIds, cancelChildren, null);
}

/**
Expand Down Expand Up @@ -1627,7 +1627,7 @@ public void updateWorkflowAttributes(
*/
public <T, E extends Exception> @NonNull WorkflowHandle<T, E> resumeWorkflow(
@NonNull String workflowId, @Nullable String queueName) {
systemDatabase.resumeWorkflows(List.of(workflowId), queueName);
systemDatabase.resumeWorkflows(List.of(workflowId), queueName, null);
return retrieveWorkflow(workflowId);
}

Expand Down Expand Up @@ -1674,7 +1674,7 @@ public void updateWorkflowAttributes(
*/
public @NonNull List<WorkflowHandle<Object, Exception>> resumeWorkflows(
@NonNull List<String> workflowIds, @Nullable String queueName) {
systemDatabase.resumeWorkflows(workflowIds, queueName);
systemDatabase.resumeWorkflows(workflowIds, queueName, null);
return workflowIds.stream().map(this::retrieveWorkflow).toList();
}

Expand Down Expand Up @@ -1719,7 +1719,7 @@ public void deleteWorkflows(@NonNull List<String> workflowIds) {
* workflows
*/
public void deleteWorkflows(@NonNull List<String> workflowIds, boolean deleteChildren) {
systemDatabase.deleteWorkflows(workflowIds, deleteChildren);
systemDatabase.deleteWorkflows(workflowIds, deleteChildren, null);
}

/**
Expand Down
22 changes: 0 additions & 22 deletions transact/src/main/java/dev/dbos/transact/database/SendCaller.java

This file was deleted.

22 changes: 22 additions & 0 deletions transact/src/main/java/dev/dbos/transact/database/StepCaller.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package dev.dbos.transact.database;

/**
* The workflow execution a DBOS operation, such as a send or a cancel, is made from. The operation
* lands only while that execution still owns the workflow.
*/
public sealed interface StepCaller {
/** The calling workflow. */
String workflowId();

/** The token of the calling workflow's execution. */
String ownerXid();

/** A call from the workflow body, recorded as the workflow's step {@code stepId}. */
record FromWorkflow(String workflowId, int stepId, String ownerXid) implements StepCaller {}

/**
* A call from inside a step, which records nothing of its own but is still checked against the
* owner.
*/
record FromStep(String workflowId, String ownerXid) implements StepCaller {}
}
Loading
Loading