use of com.uber.cadence.internal.replay.StartChildWorkflowExecutionParameters in project cadence-client by uber-java.
the class SyncDecisionContext method executeChildWorkflowOnce.
/**
* @param executionResult promise that is set bu this method when child workflow is started.
*/
private Promise<byte[]> executeChildWorkflowOnce(String name, ChildWorkflowOptions options, byte[] input, CompletablePromise<WorkflowExecution> executionResult) {
StartChildWorkflowExecutionParameters parameters = new StartChildWorkflowExecutionParameters.Builder().setWorkflowType(new WorkflowType().setName(name)).setWorkflowId(options.getWorkflowId()).setInput(input).setChildPolicy(options.getChildPolicy()).setExecutionStartToCloseTimeoutSeconds(options.getExecutionStartToCloseTimeout().getSeconds()).setDomain(options.getDomain()).setTaskList(options.getTaskList()).setTaskStartToCloseTimeoutSeconds(options.getTaskStartToCloseTimeout().getSeconds()).setWorkflowIdReusePolicy(options.getWorkflowIdReusePolicy()).build();
CompletablePromise<byte[]> result = Workflow.newPromise();
Consumer<Exception> cancellationCallback = context.startChildWorkflow(parameters, executionResult::complete, (output, failure) -> {
if (failure != null) {
runner.executeInWorkflowThread("child workflow failure callback", () -> result.completeExceptionally(mapChildWorkflowException(failure)));
} else {
runner.executeInWorkflowThread("child workflow completion callback", () -> result.complete(output));
}
});
CancellationScope.current().getCancellationRequest().thenApply((reason) -> {
cancellationCallback.accept(new CancellationException(reason));
return null;
});
return result;
}
Aggregations