Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -393,14 +393,22 @@ public String toString() {
static final class ChildWorkflowData {

final TestWorkflowService service;
final String workflowId;
final String workflowType;
final UserMetadata metadata;
StartChildWorkflowExecutionInitiatedEventAttributes initiatedEvent;
long initiatedEventId;
long startedEventId;
WorkflowExecution execution;

public ChildWorkflowData(TestWorkflowService service, UserMetadata metadata) {
public ChildWorkflowData(
TestWorkflowService service,
String workflowId,
String workflowType,
UserMetadata metadata) {
this.service = service;
this.workflowId = workflowId;
this.workflowType = workflowType;
this.metadata = metadata;
}

Expand Down Expand Up @@ -568,8 +576,8 @@ public static StateMachine<ActivityTaskData> newActivityStateMachine(
}

public static StateMachine<ChildWorkflowData> newChildWorkflowStateMachine(
TestWorkflowService service, UserMetadata metadata) {
return new StateMachine<>(new ChildWorkflowData(service, metadata))
TestWorkflowService service, String workflowId, String workflowType, UserMetadata metadata) {
return new StateMachine<>(new ChildWorkflowData(service, workflowId, workflowType, metadata))
.add(NONE, INITIATE, INITIATED, StateMachines::initiateChildWorkflow)
.add(INITIATED, START, STARTED, StateMachines::childWorkflowStarted)
.add(INITIATED, FAIL, FAILED, StateMachines::startChildWorkflowFailed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,8 @@ private void processStartChildWorkflow(
long workflowTaskCompletedId) {
a = validateStartChildExecutionAttributes(a);
StateMachine<ChildWorkflowData> child =
StateMachines.newChildWorkflowStateMachine(service, metadata);
StateMachines.newChildWorkflowStateMachine(
service, a.getWorkflowId(), a.getWorkflowType().getName(), metadata);
childWorkflows.put(ctx.getNextEventId(), child);
child.action(StateMachines.Action.INITIATE, ctx, a, workflowTaskCompletedId);
ctx.lockTimer("processStartChildWorkflow");
Expand Down Expand Up @@ -3253,13 +3254,20 @@ private DescribeWorkflowExecutionResponse describeWorkflowExecutionInsideLock()
private static PendingChildExecutionInfo constructPendingChildExecutionInfo(
StateMachine<ChildWorkflowData> sm) {
ChildWorkflowData data = sm.getData();
return PendingChildExecutionInfo.newBuilder()
.setWorkflowId(data.execution.getWorkflowId())
.setRunId(data.execution.getRunId())
.setWorkflowTypeName(data.initiatedEvent.getWorkflowType().getName())
.setInitiatedId(data.initiatedEventId)
.setParentClosePolicy(data.initiatedEvent.getParentClosePolicy())
.build();
PendingChildExecutionInfo.Builder builder =
PendingChildExecutionInfo.newBuilder()
.setWorkflowId(data.workflowId)
.setWorkflowTypeName(data.workflowType);
// These fields may not be set if the child workflow hasn't been started yet
if (data.execution != null) {
builder.setRunId(data.execution.getRunId());
}
if (data.initiatedEvent != null) {
builder
.setInitiatedId(data.initiatedEventId)
.setParentClosePolicy(data.initiatedEvent.getParentClosePolicy());
}
return builder.build();
}

private static PendingActivityInfo constructPendingActivityInfo(
Expand Down
Loading