Skip to content

Commit

Permalink
support set custom status
Browse files Browse the repository at this point in the history
Signed-off-by: Fabian Martinez <[email protected]>
  • Loading branch information
famarting committed Dec 3, 2024
1 parent e575605 commit b854457
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/workflow/client/WorkflowState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,14 @@ export class WorkflowState {
public get workflowFailureDetails(): WorkflowFailureDetails | undefined {
return this._workflowFailureDetails;
}


/**
* Gets the workflow instance's custom status, if any, as a string value.
* @returns {string | undefined} The workflow instance's custom status or undefined.
*/
public get customStatus(): string | undefined {
return this._orchestrationState.serializedCustomStatus;
}

}
9 changes: 9 additions & 0 deletions src/workflow/runtime/WorkflowContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,15 @@ export default class WorkflowContext {
this._innerContext.continueAsNew(newInput, saveEvents);
}

/**
* Sets the custom status
*
* @param status {string} The new custom status
*/
public setCustomStatus(status: string): void {
this._innerContext.setCustomStatus(status);
}

/**
* Returns a task that completes when all of the provided tasks complete or when one of the tasks fail
*
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/workflow/workflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe("Workflow", () => {
current = yield ctx.callActivity(plusOne, current);
numbers.push(current);
}

ctx.setCustomStatus("foo");
return numbers;
};

Expand All @@ -93,6 +93,7 @@ describe("Workflow", () => {
expect(state?.runtimeStatus).toEqual(WorkflowRuntimeStatus.COMPLETED);
expect(state?.serializedInput).toEqual(JSON.stringify(1));
expect(state?.serializedOutput).toEqual(JSON.stringify([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]));
expect(state?.customStatus).toEqual("foo");
}, 31000);

it("should be able to run fan-out/fan-in", async () => {
Expand Down

0 comments on commit b854457

Please sign in to comment.