Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Update WorkflowExecutor.java #3875

Closed
wants to merge 6 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -154,36 +154,43 @@ public void initWorkers(String packagesToScan) {
annotatedWorkerExecutor.initWorkers(packagesToScan);
}

public CompletableFuture<Workflow> executeWorkflow(String name, Integer version, Object input) {
CompletableFuture<Workflow> future = new CompletableFuture<>();
private String startWorkflow(
String name, Integer version, WorkflowDef workflowDef, Object input) {
Map<String, Object> inputMap = objectMapper.convertValue(input, Map.class);

StartWorkflowRequest request = new StartWorkflowRequest();
request.setInput(inputMap);
request.setName(name);
request.setVersion(version);
request.setWorkflowDef(workflowDef);

String workflowId = workflowClient.startWorkflow(request);
return workflowClient.startWorkflow(request);
}

public String executeWorkflowFuture(String name, Integer version, Object input) {
String workflowId = this.startWorkflow(name, version, null, input);
CompletableFuture<Workflow> future = new CompletableFuture<>();
runningWorkflowFutures.put(workflowId, future);
return workflowId;
}

public CompletableFuture<Workflow> executeWorkflow(String name, Integer version, Object input) {
String workflowId = this.startWorkflow(name, version, null, input);
CompletableFuture<Workflow> future = new CompletableFuture<>();
runningWorkflowFutures.put(workflowId, future);
return future;
}

public CompletableFuture<Workflow> executeWorkflow(
ConductorWorkflow conductorWorkflow, Object input) {

String workflowId =
this.startWorkflow(
conductorWorkflow.getName(),
conductorWorkflow.getVersion(),
conductorWorkflow.toWorkflowDef(),
input);
CompletableFuture<Workflow> future = new CompletableFuture<>();

Map<String, Object> inputMap = objectMapper.convertValue(input, Map.class);

StartWorkflowRequest request = new StartWorkflowRequest();
request.setInput(inputMap);
request.setName(conductorWorkflow.getName());
request.setVersion(conductorWorkflow.getVersion());
request.setWorkflowDef(conductorWorkflow.toWorkflowDef());

String workflowId = workflowClient.startWorkflow(request);
runningWorkflowFutures.put(workflowId, future);

return future;
}

Expand Down