Skip to content

Commit

Permalink
fix commented code
Browse files Browse the repository at this point in the history
  • Loading branch information
antmendoza committed Apr 30, 2024
1 parent 9fd4389 commit c8742b1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 31 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ subprojects {
apply plugin: 'com.diffplug.spotless'

compileJava {
// options.compilerArgs << "-Werror"
options.compilerArgs << "-Werror"
}

java {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,40 +25,27 @@
import io.temporal.workflow.ChildWorkflowOptions;
import io.temporal.workflow.Promise;
import io.temporal.workflow.Workflow;
import java.util.ArrayList;
import java.util.List;

public class ParentWorkflowImpl implements ParentWorkflow {
@Override
public WorkflowExecution executeParent() {

final List<Promise<WorkflowExecution>> promises = new ArrayList<>();

for (int i = 0; i < 1000; i++) {
// We set the parentClosePolicy to "Abandon"
// This will allow child workflow to continue execution after parent completes
ChildWorkflowOptions childWorkflowOptions =
ChildWorkflowOptions.newBuilder()
.setWorkflowId("childWorkflow" + Math.random())
.setParentClosePolicy(ParentClosePolicy.PARENT_CLOSE_POLICY_ABANDON)
.build();

// Get the child workflow stub
ChildWorkflow child =
Workflow.newChildWorkflowStub(ChildWorkflow.class, childWorkflowOptions);
// Start the child workflow async
Async.function(child::executeChild);
// Get the child workflow execution promise
Promise<WorkflowExecution> childExecution = Workflow.getWorkflowExecution(child);
// Call .get on the promise. This will block until the child workflow starts execution (or
// start
// fails)

promises.add(childExecution);
}

Promise.allOf(promises).get();

return promises.get(0).get();
// We set the parentClosePolicy to "Abandon"
// This will allow child workflow to continue execution after parent completes
ChildWorkflowOptions childWorkflowOptions =
ChildWorkflowOptions.newBuilder()
.setWorkflowId("childWorkflow")
.setParentClosePolicy(ParentClosePolicy.PARENT_CLOSE_POLICY_ABANDON)
.build();

// Get the child workflow stub
ChildWorkflow child = Workflow.newChildWorkflowStub(ChildWorkflow.class, childWorkflowOptions);
// Start the child workflow async
Async.function(child::executeChild);
// Get the child workflow execution promise
Promise<WorkflowExecution> childExecution = Workflow.getWorkflowExecution(child);
// Call .get on the promise. This will block until the child workflow starts execution (or start
// fails)
return childExecution.get();
}
}

0 comments on commit c8742b1

Please sign in to comment.