Skip to content

Commit

Permalink
Merge pull request #324 from conductor-oss/sub_workflow_priority
Browse files Browse the repository at this point in the history
Make Sub workflow Priority Object to support parametrised priority
  • Loading branch information
manan164 authored Nov 29, 2024
2 parents c67b2eb + 33d42ab commit fdf354f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class SubWorkflowParams {
private IdempotencyStrategy idempotencyStrategy;

// Priority of the sub workflow, not set inherits from the parent
private Integer priority;
private Object priority;

public String getIdempotencyKey() {
return idempotencyKey;
Expand All @@ -64,11 +64,11 @@ public void setIdempotencyStrategy(IdempotencyStrategy idempotencyStrategy) {
this.idempotencyStrategy = idempotencyStrategy;
}

public Integer getPriority() {
public Object getPriority() {
return priority;
}

public void setPriority(Integer priority) {
public void setPriority(Object priority) {
this.priority = priority;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import java.util.*;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -77,14 +78,17 @@ public List<TaskModel> getMappedTasks(TaskMapperContext taskMapperContext) {
TaskModel subWorkflowTask = taskMapperContext.createTaskModel();
subWorkflowTask.setTaskType(TASK_TYPE_SUB_WORKFLOW);
subWorkflowTask.addInput("subWorkflowName", subWorkflowName);
subWorkflowTask.addInput("priority", resolvedParams.get("priority"));
subWorkflowTask.addInput("subWorkflowVersion", subWorkflowVersion);
subWorkflowTask.addInput("subWorkflowTaskToDomain", subWorkflowTaskToDomain);
subWorkflowTask.addInput("subWorkflowDefinition", subWorkflowDefinition);
subWorkflowTask.addInput("workflowInput", taskMapperContext.getTaskInput());
subWorkflowTask.setStatus(TaskModel.Status.SCHEDULED);
subWorkflowTask.setCallbackAfterSeconds(workflowTask.getStartDelay());
if (subWorkflowParams.getPriority() != null) {
subWorkflowTask.setWorkflowPriority(subWorkflowParams.getPriority());
if (subWorkflowParams.getPriority() != null
&& !StringUtils.isEmpty(subWorkflowParams.getPriority().toString())) {
int priority = Integer.parseInt(subWorkflowParams.getPriority().toString());
subWorkflowTask.setWorkflowPriority(priority);
}
LOGGER.debug("SubWorkflowTask {} created to be Scheduled", subWorkflowTask);
return List.of(subWorkflowTask);
Expand All @@ -109,6 +113,7 @@ private Map<String, Object> getSubWorkflowInputParameters(
WorkflowModel workflowModel, SubWorkflowParams subWorkflowParams) {
Map<String, Object> params = new HashMap<>();
params.put("name", subWorkflowParams.getName());
params.put("priority", subWorkflowParams.getPriority());

Integer version = subWorkflowParams.getVersion();
if (version != null) {
Expand Down

0 comments on commit fdf354f

Please sign in to comment.